Response Headers

Understand response header mapping in the REST API.

We'll cover the following...

HTTP Response headers

An API response can have custom headers containing information useful for processing the response. To get a feel, invoke any API from Postman, and then look at the headers in the response section. It looks like this:

Press + to interact
Response headers
Response headers

Each value contains information that can provide vital insights into API processing. We might not directly use each field in the code. However, some of these fields are used internally. For example, the Content-Type is used by the HTTP library in our code. The response body is parsed based on the value of this content type.

Similarly, we can see two headers added by AWS, namely the API Gateway ID and the X-Ray trace ID. These are useful when logging, tracing, and debugging. When we invoke an API, AWS adds these custom headers at the API Gateway. They’re carried along with the request throughout its ...