Just wanted a clarification of the form content types:
application/x-www-form-urlencoded
: This is where you can send params encoded with the url.multipart/form-data
: ??
I need to send a JSON in the post (so it would have the type: text/x-json
, I guess).
So the question is, is multipart/form-data
suitable for this purpose / is application/x-www-form-urlencoded
better?
Also, would it be possible to send some params encoded in the url, and some data in the json?
is used when you want to upload files to the server. Please check this article for details.
I have wondered the same thing. Basically it appears that the html spec has different content types for html and form data. Json only has a single content type.
According to the spec, a POST of json data should have the content-type:
application/json
Relevant portion of the HTML spec
Relevant portion of the JSON spec
It looks like people answered the first part of your question (use application/json).
For the second part: It is perfectly legal to send query parameters in a HTTP POST Request.
Example:
Query parameters are commonly used in a POST request to refer to an existing resource. The above example would update the email address of an existing member with the id of 1234.