Click here to Skip to main content
15,791,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to get a token from a ws but so far I have not succeeded. From postman if I get the token but from my vbnet application no. The code I use in vbnet is:

Dim client = New RestClient("")
Dim request2 = New RestRequest(Method.POST)
request2.AddParameter("application/json", ParameterType.RequestBody)
request2.RequestFormat = DataFormat.Json
request2.AddParameter("Username", UserVar)
request2.AddParameter("Password", PasswVar)
Dim response2 As RestResponse = client.Execute(request2)

What I have tried:

The result obtained in vbnet in statuscode is 0, but in postman it is 200 ok

I am programming in visual studio 2015. Thanks
Updated 4-Jan-23 0:58am
Andre Oosthuizen 4-Jan-23 6:03am    
I am not versed in rest api requests. I did however found THIS link which describes in detail the process to follow. Hope it helps.
Richard Deeming 5-Jan-23 11:01am    
request2.AddParameter("application/json", ParameterType.RequestBody)

As far as I can see, that sets the request body to the literal string application/json, which is almost certainly not what you want.

You need to capture the request sent by your code, and compare it to the request sent from Postman to see what the difference is.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900