Home How to call SSRS Rest-Api V1.0 with custom security implemented (NOT SOAP)
Reply: 0

How to call SSRS Rest-Api V1.0 with custom security implemented (NOT SOAP)

user2105
1#
user2105 Published in April 23, 2018, 9:32 am

I have implemented the custom security on my reporting services 2016 and it displays the login page once the URL for reporting services is typed on browser URL bar (either reports or reportserver)

I am using the following code to pass the Credentials when i use the code WITHOUT my security extension it works and looks like this

ICredentials _executionCredentials;

CredentialCache myCache = new CredentialCache();
Uri reportServerUri = new Uri(ReportServerUrl);
myCache.Add(new Uri(reportServerUri.GetLeftPart(UriPartial.Authority)),
                 "NTLM", new NetworkCredential(MyUserName, MyUserPassword));
_executionCredentials = myCache;

when i use the code WITH the security extension it doesnt work and looks like this

ICredentials _executionCredentials;
CredentialCache myCache = new CredentialCache();
Uri reportServerUri = new Uri(ReportServerUrl);

myCache.Add(new Uri(reportServerUri.GetLeftPart(UriPartial.Authority)),
                "Basic", new NetworkCredential(MyUserName, MyUserPassword));
_executionCredentials = myCache;

and i get an Exception saying "The response to this POST request did not contain a 'location' header. That is not supported by this client." when i actually use this credentials

Is "basic" the wrong option ?

Have anyone done this ?


Update 1 Well it turns out that my SSRS is expecting an Authorisation cookie which i am unable to pass (according to fiddler, there is no cookie)

HttpWebRequest request;
request = (HttpWebRequest)HttpWebRequest.Create("http://mylocalcomputerwithRS/Reports_SQL2016/api/v1.0");
CookieContainer cookieJar = new CookieContainer();
request.CookieContainer = cookieJar;
Cookie authCookie =  new Cookie("sqlAuthCookie", "username:password");
authCookie.Domain = ".mydomain.mylocalcomputerwithRS";
if (authCookie != null)
    request.CookieContainer.Add(authCookie);
request.Timeout = -1;

HttpWebResponse myHttpWebResponse = (HttpWebResponse)request.GetResponse();
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.61569 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO