Specifying HTTP headers
Certain request customizations require setting HTTP headers. Content-Type and Accept headers control input and output format. The Range header controls pagination. The Compression header controls compression.
Content-Type and Accept headers
To specify the content types of the request body and output, use the Content-Type and Accept headers.
Header name | Value | Description |
---|---|---|
Content-Type |
application/json |
Indicates that the request body format is JSON. |
application/xml |
Indicates that the request body format is XML. | |
application/x-www-form-urlencoded |
Indicates that the request body is URL encoded. | |
Accept |
application/json |
Sets output type to JSON. |
application/json;indent=2 |
Sets output type to formatted JSON. | |
application/xml |
Sets output type to XML. |
Range
The Range
header controls pagination in List API calls.
Header name | Value | Description |
---|---|---|
Range |
items=x-y |
Returns records with row IDs x through y . Alternatively,
you can specify range in the request URL with the parameter _range=x-y . |
Compression
To compress the data in a response, set the Accept-Encoding
header.
Header name | Value | Description |
---|---|---|
Accept-Encoding |
gzip |
Returns compressed results with GNU .ZIP format. |
identity |
Returns results with identity encoding (no transformation). |
X-HTTP-Method-Override
If you are unable to use an HTTP verb in a request, send a POST
request with the
verb as the value for the override header. The request behaves as if the call is made with the HTTP
verb indicated in the override header.
For example, if you are unable to pass a
DELETE
request for order number
12345, set the X-HTTP-Method-Override
header to DELETE
and use the
HTTP
request:POST https://host:port/contextRoot/restapi/order/12345
You can also use the
X-HTTP-Method-Override
header to pass parameters in
GET
requests that exceed the size limit of a URL. Do a POST
to the
URL, set the Content-Type
header to
application/x-www-form-urlencoded
, and set the
X-HTTP-Method-Override
header to GET
. Header Name | Value |
---|---|
X-HTTP-Method-Override |
GET |
PATCH |
|
DELETE |