Where should the parameters values be for this REST API and why?
-
27-10-2019 - |
Question
I have the following REST API:
POST /users/martin/notify/...
The API is suppose to notify a list of users that the user Martin has something to say. The list of users to be notified can vary from 1 to a thousand. Where the list of a thousand users should be: Querystring, HTTP Header or the Request body? Why?
Solution
Request body. Headers and querystrings often have size limitations in practice that you would definitely hit with a thousand identifiers. At a more theoretical level, the request body should be the entity which you wish the server to process via POST. Headers are for protocol-level metadata about that entity; that is, information that helps the entity be processed, but not the entity itself. Querystrings are part of the identifier for the resource, and also not a representation of that resource.