andyburke / UnityHTTP

A TcpClient-based HTTP library for Unity.
GNU General Public License v2.0
592 stars 146 forks source link

JSON body in Form post #35

Closed omarojo closed 9 years ago

omarojo commented 9 years ago

Is there a way to make this request using your library ? curl -k -F "request={'timezone':'America/New_York', 'lang':'en'};type=application/json" -F "voiceData=@hello.wav;type=audio/wav" -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "ocp-apim-subscription-key: YOUR_SUBSCRIPTION_KEY" https://api.api.ai/v1/query

As you can see its a form with JSON body and a binary file. But I just can't understand if your library can do this.

andyburke commented 9 years ago

Yes, there is an example in the readme to send a post request with a json body. You need to pass a Hashtable with the relevant key/value pairs.

omarojo commented 9 years ago

Yes, but this form, also contains a binary, is not just JSON.

andyburke commented 9 years ago

I see. You are sending from data that includes json. Use the form data example in the readme and encode the json as a string in one of the values.