REST request as URL or JSON

Im working on a REST API, responding to request JSON data. (Content-type: application / JSON). But are there any right or wrong values ​​regarding the content type of my POST and GET request . Should it be JSON or url-encoded, or does it not matter?

+4
source share
1 answer

Requests only POST and PUT send the body and, therefore, have the type of content of the request. GET requests do not have a content type.

If your request conceptually creates / updates a resource, use the POST or PUT method and accept JSON as the request body. (If you want to accept data application/x-www-form-urlencoded, as well as (or not) JSON, it depends on your requirements, this is not a “right” or “wrong” question here).

If your request has access / resource request , use GET and encode any relevant parameters in the URL (either as a query string or in the URL itself).

: "RESTful" , . , (, Wikipedia http://en.wikipedia.org/wiki/Representational_state_transfer )

+5

All Articles