(using C#, Web API, SQL Server2012 w/report server, authentication is NTLM)
I am getting an intermittent error when attempting to download a report (as an excel document) from SSRS. I build out the correct URL to render the report like:
WebClient webClient = new WebClient();
webClient.Credentials = new NetworkCredential("myDom\\myReportReader", "P@55W0rd");
//string credentials = Convert.ToBase64String(
// Encoding.ASCII.GetBytes("myDom\\myReportReader" + ":" + P@55W0rd"));
//webClient.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", credentials);
//401 Unauthorized thrown here:
return new MemoryStream(webClient.DownloadData(reportUrl));
The goal here is that a Web API controller on public facing IIS downloads the filestream from an internal/firewall protected SSRS and then relays the stream to browser. This WORKS sometimes...when it doesn't it returns a 401 error on the last line... The remarked out line represent an attempt to resolve the problem which did not work.