Breadcrumbs

Request headers

HTTP headers in an API request are essential for controlling how the API handles those requests and generates its responses.

The required header

To ensure proper API interaction and receive responses in the expected format, all API requests must include the HTTP Accept header set to application/json.

Accept: application/json

This header is crucial for the server (backend) to understand if the client supports JSON-formatted responses. It ensures that the server will return all data, including error messages, in JSON format.

Failure to include this header may cause the server to return responses in an unintended format (e.g., HTML), even for errors, because it lacks a clear indication of your preferred data type.

Additional headers

header 'Content-Type: application/json'

This header specifies the format of the request body, letting the server know that the body is encoded in JSON.

It's mandatory for requests that include a body, such as POST, PUT, or PATCH requests.

For GET requests, it's optional.