4

I am using an online NLP API called Wit.ai. I am sending an http web request, and I get a response, and that all works perfectly fine. However, now I need to know how to POST this JSON:

 {
   "state": "email_or_text"
 }

As an addition to this code:

 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

Thanks for your help!

Blacksad
  • 14,906
  • 15
  • 70
  • 81
user3567163
  • 53
  • 1
  • 1
  • 5

1 Answers1

2

Check this code at http://dotnetpad.com/9O883hmI it has a quick example of a POST method that can get you started on posting your JSON. Modify the URL and the content string and hit Run and see the results!

firas489
  • 131
  • 5