HTTP Headers
To negotiate the content type being sent
between the client and service, the request includes an Accept
header to indicate the acceptable media type. Optionally, it can also indicate the
MIMEContent-Type being sent in the request.
The response from the server will return a
status code and the Content-Type of the response.
The following are example HTTP content negotiation headers for JSON and XML:
- JSON
-
Accept: application/json; charset=utf-8 Content-Type: application/json; charset=utf-8 - XML
-
Accept: application/xml; charset=utf-8 Content-Type: application/xml; charset=utf-8
The following table defines the type of response to expect based on the header information specified in the request.
| Request | Header Information | Response Content Type |
|---|---|---|
| service_name.json | No special header information. | json |
| service_name.json |
Content-Type: application/xml; charset=utf-8 |
xml |
| service_name.json |
Content-Type: application/json; charset=utf-8 |
json |
| service_name |
Content-Type: application/json; charset=utf-8 |
json |
| service_name |
Content-Type: application/xml; charset=utf-8 |
xml |
| service_name | No special header information. | json |
| service_name.xml |
Content-Type: application/json; charset=utf-8 |
json |
| service_name.xml |
Content-Type: application/xml; charset=utf-8 |
xml |
| service_name.xml | No special header information. | xml |