我正在使用一个名为 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/