Home > Back-end >  How to override request id send to aws api gateway
How to override request id send to aws api gateway

Time:06-24

AWS Api Gateway docs is crystal clear about the capacity of API Clients override de Request ID here:

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference

More specific on the $context.requestId description: "An ID for the request. Clients can override this request ID. Use $context.extendedRequestId for a unique request ID that API Gateway generates."

I'm trying to send an requestId to override the one generated inside Api Gateway, but i'm cant figure out how.

Any one knows hot to do that?

CodePudding user response:

You do this by adding the same header to the ingoing request:

x-amzn-RequestId=ABC123

This will cause the $context.requestId to equal ABC123, and the extendedRequestId will be the shorter random char string value. There will not be a UUID type Id given.

  • Related