Hi,
I am getting ready to create a .net wrapper for the bcs, but I am having a very difficult time getting past the authentication.
has anyone tried to connect with a non Browser web request and get past the 401.
I have tried several things to handle the basic html 1.0 authentication, but everything I have tried so far still returns a 401 to me.
BSC authentication
Re: BSC authentication
It's a little particular about how it works.
Try this:
Dim request As HttpWebRequest = Nothing
request = HttpWebRequest.Create(YourURL & Process)
request.KeepAlive = False
request.Timeout = 6000
request.Method = method
request.PreAuthenticate = True
request.ContentType = "application/x-www-form-urlencoded"
request.Credentials = New NetworkCredential(txtUSERNAME.Text, txtUSERPASS.Text)
request.ProtocolVersion = HttpVersion.Version10
Dim response As HttpWebResponse = request.GetResponse()
If response.StatusCode = HttpStatusCode.OK Then
Dim responseStream As StreamReader = New StreamReader(response.GetResponseStream())
responseData = responseStream.ReadToEnd()
End If
response.Close()
Let me know if you still having issues and I'll send you the whole function.
Regards
Try this:
Dim request As HttpWebRequest = Nothing
request = HttpWebRequest.Create(YourURL & Process)
request.KeepAlive = False
request.Timeout = 6000
request.Method = method
request.PreAuthenticate = True
request.ContentType = "application/x-www-form-urlencoded"
request.Credentials = New NetworkCredential(txtUSERNAME.Text, txtUSERPASS.Text)
request.ProtocolVersion = HttpVersion.Version10
Dim response As HttpWebResponse = request.GetResponse()
If response.StatusCode = HttpStatusCode.OK Then
Dim responseStream As StreamReader = New StreamReader(response.GetResponseStream())
responseData = responseStream.ReadToEnd()
End If
response.Close()
Let me know if you still having issues and I'll send you the whole function.
Regards
Re: BSC authentication
yes that worked.
The line I was missing was the content type
thanks
The line I was missing was the content type
thanks
Re: BSC authentication
Cool, by the way, the ContentType listed in my previous post is the one I use for the "GET" method. For the "POST" method I use:
request.ContentType = "text/html".
request.ContentType = "text/html".