I’m designing a REST API, and I would like to know the proper way to allow for data passing from the client to a GET request using REST semantics.
A simple use case is, when fetching some data from the server, I’d like the client to have the option to pass a list of hashes of the data that is already present in the client, so that the server can exclude that data in its response if the data hasn’t changed.
A quick search reveals that using query strings would be the right way to do so.
For example,
GET /api/v1/Products?productsInClient?id1=MD5_HASH_1&id2=MD5_HASH_2 could be one design.
However, I’d ideally like to pass the query string data in the request body since the number of ids in the query string can become really long. Is it acceptable to pass such information in the body of a GET request and still conform to REST semantics.
Another option is to make this a POST request – but I’d hate to do that since the request doesn’t really create a new resource on the server. The only additional server operation is the exclusion of certain resources already present in the client.
You could use a custom http header for this.
There could be also problems with some web servers (iis 6 for example, see here) that have limitations related to the lenght of the urls, length that can be set to a maximum size for security reason as well explained here