Archived Forum Post

Index of archived forum posts


Sending json struct with http request

Sep 02 '13 at 10:25

I am currently sending json data successfully to a 3rd party API: using req.AddParam like this:


I am trying to use a different service that uses a struct for the parameters:

I am having trouble figuring out how to make this work with req.AddParam. Should it work like this?

req.AddParam("message", "{"html": "

Example HTML content

","text": "Example text content","subject": "example subject"}")


When using AddParam, you're not actually sending a JSON request. You must be sending either an application/x-www-form-urlencoded or a multipart/form-data request. It must be that for "", it accepts either JSON HTTP requests in addition to the other standard ways of providing name/value params.

For, I suspect it's only accepting JSON requests -- where the Content-Type is either application/jsonrequest or application/json, and the body of the HTTP request is the JSON struct itself. You would achieve this by calling either PostJson or PostJson2.