Page 1 of 1

BSC authentication

Posted: Tue Sep 24, 2013 3:49 pm
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.

Re: BSC authentication

Posted: Tue Sep 24, 2013 6:06 pm
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

Re: BSC authentication

Posted: Tue Sep 24, 2013 11:16 pm
by luckyj13
yes that worked.
The line I was missing was the content type

thanks

Re: BSC authentication

Posted: Wed Sep 25, 2013 2:22 pm
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".