Ask Your Question

Revision history [back]

To add a requestId to the request body using a mapping template in API Gateway, you can use the following steps:

  1. In the API Gateway console, go to your API's Resources page and select the desired resource method.
  2. Click on the Integration Request card to show the integration options.
  3. Under Mapping Templates, create a new mapping template by selecting "Add mapping template".
  4. Select "application/json" as the Content-Type and enter the input for the new mapping template.
  5. To add the requestId to the request body, use the following code in the template:
{
  "requestId": "$context.requestId"
}
  1. Click "Save".
  2. Finally, deploy the updated API. Once deployed, the requestId will be added to the request body of all incoming requests.