Reputation: 61483
I'm designing my API, and I specify an optional API version in the URL
GET /Issuer/{certificate-name}/versions?api-version=2016-10-01[&maxresults]
Should I also have one specified in the HTTP Header (for flexibility)?
What should I do if there is a conflict between the two approaches?
Upvotes: 1
Views: 241
Reputation: 4025
There is no obvious advantage to allowing an input of API version from 2 different input methods (querystring, and Header). However, the disadvantage here is conflict resolution if both are specified by the client.
There is no right or wrong way of where an API version should be specified, whether in the header or the querystring. But keep in mind that URLs require parsing, while mostly done the by framework, but still a compute resource you are spending to parse the URL to extract the value from.
I (personally) prefer using the header out of simplicity. Plus it feels more cleaner to keep the URL as an address only to point to the function/intent of the client.
Upvotes: 1