WebRequest giving "Not Authorized" error  
Author Message
SKK*





PostPosted: Visual Basic General, WebRequest giving "Not Authorized" error Top

Hi. I'm trying to connect to a web page from vb. The web page is not to be displayed but only to return results. I have already done something similar and it is working, the difference is in the past I was passing an XML request stream and this time the input data is all in the querystring. I'm able to test this using the same querystring in a browser window and it works, but I can't get it to work in the code. The only error it gives is "Unauthorized" when it hits the GetResponse() line. I'm hoping that I'm just missing a simple step. Here's the code. Thanks!!

Dim passwd As String = "xxxxxx"

Dim userid As String = "xxxxx"

Dim myCred As New NetworkCredential(userid, passwd)

Dim RWQS as String

RWQS = https://URI+querystring of site I'm trying to connect to

Dim myReq As WebRequest = WebRequest.Create(RWQS)

myReq.Credentials = myCred

myReq.Method = "GET"

myReq.PreAuthenticate = True

Dim myResponse As WebResponse = myReq.GetResponse()



Visual Basic13