From what I read about RESTful, you can only use GET
, POST
, PUT
, PATCH
, and DELETE
.
The GET
and DELETE
are not expected to include a body. As @VoiceOfUnreason mentioned, this is mainly because caches can have difficulties handling a body along a GET
. That being said, if your results are never cached, it should not be a concern at all. (i.e. return Cache: no-cache
and other similar HTTP header from your server.)
There is no real convention on the Query String and supporting lists or JSON and such. If you want to keep a GET
, you could use an encoded JSON string, though. There is no problem with that, except the length of the URL.
http://www.example.com/?query=<encoded-json>
(encoded just means that you have to properly escape URI special characters, what the JavaScript encodeURICompent()
function does.)
The length of the URL should be kept under 1Kb to be 100% safe. You can do some research on it, I think that the browser with the most stringent limit is around 2k.
If you want to use a bigger query, then you should revert your queries to using a POST
and not a GET
. Then the buffer is normal in that situation and the reply is not expected to be cached.
Real World Use (but Not An Excuse)
If you look into Elasticsearch, you will see that all their queries accept a JSON. You can send a DSL query using a GET
or a POST
. Either one accept a JSON in their body.
They offer the POST
because most browsers will not accept to attach a body to a GET
method. So GET
queries would not work at all from a browser.
Example of Arrays in Query Strings
There has been various libraries, and at least PHP, that added support for arrays in parameters. In most cases this is done by supporting the array syntax in the parameter name. For example:
path/?var[1]=123&var[2]=456&var[3]=789
In this case, those languages will convert the value in an array. $_GET['var'][1]
would then return 123
.
This is not a convention, just an extension of that specific environment.