【问题标题】:Need to code a CURL command to VB.net需要将 CURL 命令编码到 VB.net
【发布时间】:2016-06-27 11:59:07
【问题描述】:

我需要在 VB.net 上编写这个 Curl/json 命令。我不确定如何使用 HttpWebRequest。请帮忙!!!

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

【问题讨论】:

标签: json vb.net curl


【解决方案1】:

HttpClient 是你所追求的。

要添加标头,您只需创建一个自定义 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

【讨论】:

  • 感谢“Uno”,现在看来正在获取令牌。我现在需要做的是将结果保存为 json 格式并以某种方式显示出来。我将不胜感激!!!
  • 没问题 ;)。结果将是一个 HttpResponseMessage,result.Content.ReadAsStringAsync 应该将 JSON 数据作为字符串返回给您。
猜你喜欢
  • 1970-01-01
  • 2020-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-18
  • 1970-01-01
  • 2014-08-28
  • 1970-01-01
相关资源
最近更新 更多