3 ms·
It's not only a valid usage of accept, it's simply necessary; you can't possibly process a request for a version of a response without assuming the request cont
by gnaritas 9y ago
It's not only a valid usage of accept, it's simply necessary; you can't possibly process a request for a version of a response without assuming the request contains the necessary information said response requires. If you don't expect the Accept header asking for a specific version to affect the processing of the request, I think you really haven't thought it through as it necessarily must since the output response version must be correlated with the input request. If output version 5 requires a different set of input args, then your code for processing the output will have to assume those args present and thus will have to assume the request was formatted correctly for version 5 otherwise you'll have to throw an error saying the request was formatted incorrectly.
Yes, you could use a custom header, many do, but then you're stepping outside of the HTTP standard, the Accept header is supposed to define the response format, not some custom one you make up, and version is another facet of the response format and must imply the request format matches the required data of the requested output format.
- eridius 9y ago...what? Your comment literally makes no sense to me. > Yes, you could use a custom header, many do, but then you're stepping outside of the HTTP standard No you're not. The HTTP standard allows for custom headers, and nothing in the HTTP standard restricts servers from using customer headers to influence how they process the request. > Accept header is supposed to define the response format Yes, like application/json. It's not supposed to define the request content, just the format, and it's definitely not supposed to affect the way the request is processed. > version is another facet of the response format No it's not. JSON is a response format. XML is a response format. "API version 5" is not a response format.