BSC authentication

Applications that run on PC/Mac.
Post Reply
luckyj13
Posts: 2
Joined: Tue Sep 24, 2013 3:37 pm
Bot?: No

BSC authentication

Post by luckyj13 »

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.
User avatar
SamIam
Posts: 51
Joined: Fri Aug 19, 2011 1:34 pm
Bot?: No

Re: BSC authentication

Post by SamIam »

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
luckyj13
Posts: 2
Joined: Tue Sep 24, 2013 3:37 pm
Bot?: No

Re: BSC authentication

Post by luckyj13 »

yes that worked.
The line I was missing was the content type

thanks
User avatar
SamIam
Posts: 51
Joined: Fri Aug 19, 2011 1:34 pm
Bot?: No

Re: BSC authentication

Post by SamIam »

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".
Post Reply