none
The request failed with HTTP status 401: Unauthorized

    Question

  • Hi all,

    When I try to access the report server from my application, I get a “The request failed with HTTP status 401: Unauthorized” error.

    I used the production report server URL from my Visual Studio project on dev server and it connects and downloads the reports. Everything works fine in this scenario. But when I use the same URL in production server it gives an unauthorized error.

    The report server Url looks like, https://app.company.com:3535 and port 3535 is open for incoming connections to app.company.com(my app url).

    The production App server is in the DMZ(outside the firewall) and the database server is in their network(behind the firewall). The report server is on top of the App server.

    For the development environment, all the servers are in their network.

    Can you think of any configurations that I might be missing. I have also attached the code I’m using to connect to the report server. The reports data source is set up to use credentials stored within the report server.

    Please let me know your suggestions.

    public static byte[] GetExcelBytes(string sCriteria, string reportPath, string excelHeader)
            {
                string reportServerUrl = ConfigurationManager.AppSettings["ReportServerURL"];
                string mimeType;
                string fileExtention;
                string encoding;
                Warning[] warnings;
                string[] streamIds;
    
                ReportViewer reportViewer = new ReportViewer();
                ServerReport serverReport = reportViewer.ServerReport;
    
                serverReport.ReportServerUrl = new Uri(reportServerUrl);
                serverReport.ReportPath = reportPath;
    
                List<ReportParameter> parameters = new List<ReportParameter>();
                parameters.Add(new ReportParameter("Criteria", sCriteria));
                parameters.Add(new ReportParameter("Header",excelHeader));
                serverReport.SetParameters(parameters);
    
                byte[] exportBytes = reportViewer.ServerReport.Render("Excel", null, out mimeType, out encoding,
                                                 out fileExtention, out streamIds, out warnings);
                return exportBytes;
            }

    Thanks,

    Shashank

    Monday, October 22, 2012 3:12 PM

Answers

  • I changed the reportserver URL to https://localhost/ReportServer, since the app server and report server are on the same box. That worked for me.

    Thanks for all your inputs on this issue.

    Shashank

    Wednesday, October 24, 2012 4:44 PM

All replies

  • The report server Url looks like, https://app.company.com:3535 and port 3535 is open for incoming connections to app.company.com(my app url).


    Only incoming traffic, not for outgoing connections? How do you what to receive the result of your SSRS request, if outgoing connections are blocked?

    Olaf Helper

    Blog Xing

    Monday, October 22, 2012 4:48 PM
  • Hi Shashank,

    Generally, the 401 error occurs when the user is not authorized to the Report Server. Here, the following suggestions are for your reference:

    • If Reporting Services is configured to use Kerberos authentication, please make sure to register the Service Principal Name (SPN) for the domain user account that the Reporting Services is running under. For more information, please see: Configure Windows Authentication in Reporting Services
    • Use the HttpRquest method to access SSRS Web Service and passing credentials through NetworkCredentials.
    • Check whether the user that views the custom application has access to the report or not.

    If the issue persists, please check the detailed error from the SQL Server Reporting Services logs and refer to the following KB article:
    Troubleshooting HTTP 401 errors in IIS

    Hope this helps.

    Regards,
    Mike Yin


    Mike Yin

    TechNet Community Support

    Wednesday, October 24, 2012 8:02 AM
    Moderator
  • I changed the reportserver URL to https://localhost/ReportServer, since the app server and report server are on the same box. That worked for me.

    Thanks for all your inputs on this issue.

    Shashank

    Wednesday, October 24, 2012 4:44 PM
  • Hi Shashank,

    I am glad to hear that you have resolved the issue by yourself. Thanks for your helpful sharing. Here, I will mark your reply as answer so that this thread can help more coummunity members who encounter the same issue.

    Regards,
    Mike Yin


    Mike Yin

    TechNet Community Support

    Thursday, October 25, 2012 1:10 AM
    Moderator