R
RSH
Hi,
I am trying to access a reporting services report using the HTTPWebRequest
object but I am getting an error:
The remote server returned an error: (401) Unauthorized.
We can't seem to figure this out...the link works fine if I enter it
directly in a browser, just not when I try to hit through the HTTPWebRequest
object.
Thanks for any possible solutions!
Ron
Private Sub ReportSaveTest()
Dim strLink As String =
"http://svr/ReportServer$svr?/WebServiceTest&rs:Command=Render&rs:format=HTML4.0"
Dim myCred As New Net.NetworkCredential
myCred = New System.Net.NetworkCredential("user", "pass", "dimain")
Dim ox As System.Net.HttpWebRequest
ox = System.Net.HttpWebRequest.Create(strLink)
ox.PreAuthenticate = True
ox.Credentials = myCred
Dim oy As System.Net.HttpWebResponse = ox.GetResponse() <<<<<<<<<<<<<<
ERRORS OUT HERE
Dim raw As System.IO.FileStream = New
System.IO.FileStream(Request.PhysicalApplicationPath & "TesFile.pdf",
IO.FileMode.Create)
Dim buffer(1024) As Byte
Dim rs As System.IO.Stream = oy.GetResponseStream()
Dim read As Integer = rs.Read(Buffer, 0, Buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = rs.Read(buffer, 0, buffer.Length)
End While
oy.Close()
raw.Close()
rs.Close()
oy = Nothing
ox = Nothing
raw = Nothing
rs = Nothing
End Sub
I am trying to access a reporting services report using the HTTPWebRequest
object but I am getting an error:
The remote server returned an error: (401) Unauthorized.
We can't seem to figure this out...the link works fine if I enter it
directly in a browser, just not when I try to hit through the HTTPWebRequest
object.
Thanks for any possible solutions!
Ron
Private Sub ReportSaveTest()
Dim strLink As String =
"http://svr/ReportServer$svr?/WebServiceTest&rs:Command=Render&rs:format=HTML4.0"
Dim myCred As New Net.NetworkCredential
myCred = New System.Net.NetworkCredential("user", "pass", "dimain")
Dim ox As System.Net.HttpWebRequest
ox = System.Net.HttpWebRequest.Create(strLink)
ox.PreAuthenticate = True
ox.Credentials = myCred
Dim oy As System.Net.HttpWebResponse = ox.GetResponse() <<<<<<<<<<<<<<
ERRORS OUT HERE
Dim raw As System.IO.FileStream = New
System.IO.FileStream(Request.PhysicalApplicationPath & "TesFile.pdf",
IO.FileMode.Create)
Dim buffer(1024) As Byte
Dim rs As System.IO.Stream = oy.GetResponseStream()
Dim read As Integer = rs.Read(Buffer, 0, Buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = rs.Read(buffer, 0, buffer.Length)
End While
oy.Close()
raw.Close()
rs.Close()
oy = Nothing
ox = Nothing
raw = Nothing
rs = Nothing
End Sub