Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3667

Accessing authenticated REST API from Vb.net 4.0

$
0
0

I am trying to login into REST API from vb.net.

Dim pageSource As String    Dim formUrl As String = "http://10.23.202.18:8080/usermgmt-0.1.0.BUILD-SNAPSHOT/resources/j_spring_security_check"' NOTE: This is the URL the form POSTs to, not the URL of the form (you can find this in the "action" attribute of the HTML's form tag    Dim formParams As String = String.Format("j_username={0}&j_password={1}", "administrator", "admin")    Dim cookieHeader As String    Dim req As WebRequest = WebRequest.Create(formUrl)    req.ContentType = "application/x-www-form-urlencoded"    req.Method = "POST"    Dim bytes As Byte() = Encoding.ASCII.GetBytes(formParams)    req.ContentLength = bytes.Length    Using os As Stream = req.GetRequestStream()        os.Write(bytes, 0, bytes.Length)    End Using    Dim resp As WebResponse = req.GetResponse()    cookieHeader = resp.Headers("Set-cookie")    Using sr As New StreamReader(resp.GetResponseStream())        pageSource = sr.ReadToEnd()    End Using

But in response I am getting resp.Headers("Set-cookie"),resp.Headers("Location") as empty and in response URLgetting like:

You have tried to access a protected area of this application. By default you can login as "admin", with a password of "admin"

So please help me to come out from this.


Viewing all articles
Browse latest Browse all 3667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>