Web API Versioning
As you perform an API call, it should specify its currently used API version as part of the Zend Server API media type in the Accept HTTP header. For example, sending a request using API version 3.0 should include the following Accept header in the request:
Accept: application/vnd.zend.serverapi+xml;version=3.0
If the server supports the specified API version, it will handle the request and respond in the appropriate format, matching the specified API version. The response format and API version will be specified using the Content-type response header:
Content-type: application/vnd.zend.serverapi+xml;version=3.0
If the server is not compatible with the API version being used, the server will return an HTTP 406 Not Acceptable”response, with supported version content types listed as part of the <errorData> XML.
|
Example: <?xml version="1.0" encoding="UTF-8"?> |
|
You can then choose to switch to a different API version, or give up and issue a failure message to the end user.
Other available response formats are JSON which generally follows XML responses in structure and behavior.