Reputation: 441
When designing a REST API, what is the best practice for passing metadata you require for statistics and logging, but which doesn't change the response from the server?
For example, if I have a service to find the nearest public toilet, I may want to know whether the user's location was determined by GPS. Or if an end user's request passes through several systems, I may want to pass a request ID for debugging.
As I understand it the options are:
Query parameters
HTTP headers
Which is the right choice if the metadata is allowed to be absent?
Is the answer different if the metadata must be present, though it's value otherwise doesn't change the server's response?
Upvotes: 3
Views: 2477
Reputation: 142044
HTTP Headers is the right answer. That's what they are there for.
The web browser as a debugger is not a particularly valid considering how many other viable options exist for testing web apis. Stuff like Postman, Dev HttpClient, Fiddler, Runscope are all decent ways to test APIs.
Upvotes: 6