If an API needs to support multiple versions without changing the URL path for existing clients, where would an expert tell the client to specify which API version it wants to use?
When an API needs to support multiple versions without altering the URL path segment for existing clients, an expert would typically advise the client to specify the desired API version using two primary mechanisms: the HTTP Accept header for media type negotiation, or a custom HTTP request header. A less preferred alternative is a query parameter. First, the client can specify the API version within the HTTP Accept header. The Accept header is a standard HTTP request header sent by the client to indicate which media types, or data formats, it is capable of understanding and prefers in the server's response. For versioning, the version number is embedded directly into a custom media type. For example, a client could send an `Accept` header like `Accept: application/vnd.myapi.v2+json`. In this example, `....
Community Answers
Sign in to open profiles and full community answers.
No community answers yet. Be the first to submit one.