1

I need to code this Curl/json command on VB.net. I am not sure how to use HttpWebRequest. Please HELP!!!

curl -X GET --header "Accept: /" --header "X-Auth-Token: eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NTc3NTQ1" "http://staging-exact-integration.posios.com/PosServer/rest/core/company"

ZEQUET
  • 51
  • 1
  • 7
  • 1
    C#, not VB.net but maybe this will point you in the right direction: [Add custom header in HttpWebRequest](http://stackoverflow.com/questions/8519788/add-custom-header-in-httpwebrequest) – William Price Mar 12 '16 at 05:19

1 Answers1

1

HttpClient is what you're after.

To add headers, you simply create a custom HttpRequestMessage:

Dim client As New HttpClient()
Dim request As New HttpRequestMessage() With
{
     .RequestUri = New Uri("http://staging-exact-integration.posios.com/PosServer/rest/core/company"),
     .Method = HttpMethod.Get,
}

request.Headers.Add("X-Auth-Token", "eyJhbGciOiJIUzI1NiJ9.eyJleHAiOjE0NTc3NTQ1")

Dim result = client.SendAsync(request).Result
Stefano d'Antonio
  • 5,874
  • 3
  • 32
  • 45
  • Thanks "Uno" it looks like is taking the token now. What I need to do now is to save the results on a json format and show them somehow.I will appreciate some help!!! – ZEQUET Mar 12 '16 at 21:49
  • No problem ;). The result will be a HttpResponseMessage, and result.Content.ReadAsStringAsync should give you back the JSON data as a string. – Stefano d'Antonio Mar 13 '16 at 01:19