Quantcast
Channel: SQL Server Reporting Services
Viewing all articles
Browse latest Browse all 1418

The request failed with HTTP status 401: Unauthorized.

$
0
0

I trying get ssrs 2008 up and running on a new server.

I got everything to work just like it dit on my old server and I can deploy reports and view them in the report manager, but I cannot seem to view a report from asp.net applications either in a reportviewer or using the reportexecutionservice. I keep getting the error: The request failed with HTTP status 401: Unauthorized

This is the first time that I had to set up ssrs so I do not know whether I have missed something. I tried to make everything the same as the instance on my old server.

The following code is what I use for the web execution service and it used to work fine.

This code basically just renders the report as a pdf and downloads it.

 rs.Credentials = New System.Net.NetworkCredential("username", "password", "domainname")
                Dim reportPath As String = "/OLS/" & ReportName
                Dim ResultStream() As Byte
                Dim StreamIdentifiers() As String = Nothing
                Dim optionalParams(1) As ParameterValue
                Dim OptionalParam As String = Nothing
                Dim optionalWarnings As WebReference.Warning() = Nothing
                optionalParams(0) = New WebReference.ParameterValue
                optionalParams(0).Name = "WarningID"




                optionalParams(0).Value = Session("ID")
                ' Create and set the content type string
                Dim contentType As String = "application/pdf"
                Dim historyID As String = Nothing
                Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
                Dim format As String = "PDF"
                Dim extension As String = ""
                Dim encoding As String = ""
                Dim mimeType As String = ""
                Dim warnings As Warning() = Nothing
                Dim streamIDs As String() = Nothing

                Dim WarningID As String
                WarningID = Session("ID")


                Dim execInfo As New ExecutionInfo
                Dim execHeader As New ExecutionHeader()
                rs.ExecutionHeaderValue = execHeader
                execInfo = rs.LoadReport(reportPath, historyID)
                rs.SetExecutionParameters(optionalParams, "en-us")
                Dim FilePath As String
                FilePath = "c:\WebDocuments\OLS\TempDocs\" & Session("EmployeeID") & "\"

                Try
                    ResultStream = rs.Render(format, devInfo, extension, encoding, mimeType, warnings, streamIDs)

                    execInfo = rs.GetExecutionInfo()

                    Console.WriteLine("Execution date and time: {0}", execInfo.ExecutionDateTime)


                Catch err As SoapException
                    'Console.WriteLine(e.Detail.OuterXml)
                End Try

                ' Write the contents of the report to an MHTML file.
                Try
                    Dim stream As FileStream = File.Create(FilePath + WarningID + ".pdf", ResultStream.Length)
                    Console.WriteLine("File created.")
                    stream.Write(ResultStream, 0, ResultStream.Length)
                    Console.WriteLine("Result written to the file.")
                    stream.Close()
                Catch err As Exception
                    Console.WriteLine(err.Message)
                End Try

                'insertDownload(ClientID)
                'Response.Redirect(Request.Url.ToString)

                ' ResultStream = rs.Render("/" & sReportPath & "/" & sReportName, "PDF", Nothing, "<DeviceInfo><StreamRoot>/RSWebServiceXS/</StreamRoot></DeviceInfo>", optionalParams, Nothing, Nothing, OptionalParam, OptionalParam, optionalParams, optionalWarnings, StreamIdentifiers)
                Response.Clear()
                Response.ContentType = "application/octet-stream"
                Response.AddHeader("Content-Type", contentType)
                Response.AddHeader("Content-Disposition", "attachment;filename=" & WarningID & ".pdf")
                Response.BinaryWrite(ResultStream)
                Response.Flush()
                Response.End()


            End Using


Viewing all articles
Browse latest Browse all 1418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>