json - 使用 VB.NET 在 URL HTTP Web 请求上发布 JSON

标签 json vb.net http post wit.ai

我正在使用一个名为 Wit.ai 的在线 NLP API。我正在发送一个 http 网络请求,我得到了一个响应,并且一切正常。但是,现在我需要知道如何发布这个 JSON:

 {
   "state": "email_or_text"
 }

作为此代码的补充:

 Function getJson()
    Dim editedText As String = TextBox1.Text.Replace(" ", "%20")
    Dim myHttpWebRequest = CType(WebRequest.Create("https://api.wit.ai/message?v=20140609&q=" + editedText + "&units=metric"), HttpWebRequest)
    myHttpWebRequest.Headers.Add("Authorization: Bearer <myauthcode>")
    Dim myHttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
    Dim myWebSource As New StreamReader(myHttpWebResponse.GetResponseStream())
    Dim myPageSource As String = myWebSource.ReadToEnd()
    Return myPageSource
End Function

感谢您的帮助!

最佳答案

http://dotnetpad.com/9O883hmI 检查此代码 它有一个 POST 方法的快速示例,可以让您开始发布 JSON。 修改 URL 和内容字符串并点击运行并查看结果!

关于json - 使用 VB.NET 在 URL HTTP Web 请求上发布 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24457191/

相关文章:

json - Go:如何将响应体变成请求体?

vb.net - 发送邮件(交易失败。服务器响应为 : Relay rejected for policy reasons)

javascript - 使用 ClientScript 类将 VB.net 数组传递给 javascript

javascript - fetch() 不发送标题?

java - HttpMessageConverter 异常 : RestClientException: Could not write request: no suitable HttpMessageConverter found

javascript - 无法将对象传递给history.push()

javascript - 将 png 图像从 json 链接到 html

vb.net - 在 ZPL 标签打印机上使用位图

javascript - Mailgun HTTP 错误代码 400 错误请求

java - 如何在Spring中使用restTemplate通过请求主体发出GET请求