最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

amazon web services - API Gateway SQS Integration - MessageAttributes not being sent - Stack Overflow

programmeradmin0浏览0评论

I am trying to include the API Gateway Request Id in my SQS message, so that I can log it in the consuming Lambda for tracing.

My mapping template is as follows:

Action=SendMessage&MessageBody=$util.urlEncode($input.body)&MessageAttribute.1.Name=RequestId&MessageAttribute.1.Value.StringValue=$context.requestId&MessageAttribute.1.Value.DataType=String

When I test this via the API Gateway "Test" tab, I can see the request Id exists as part of the MessageAttributes of my SQS message.

However, when I call the API Gateway endpoint via Postman, the request still goes through API Gateway > SQS > Lambda, but there are no message attributes.

Does anyone know why there could be this difference between the test functionality and calling the endpoint?

I am trying to include the API Gateway Request Id in my SQS message, so that I can log it in the consuming Lambda for tracing.

My mapping template is as follows:

Action=SendMessage&MessageBody=$util.urlEncode($input.body)&MessageAttribute.1.Name=RequestId&MessageAttribute.1.Value.StringValue=$context.requestId&MessageAttribute.1.Value.DataType=String

When I test this via the API Gateway "Test" tab, I can see the request Id exists as part of the MessageAttributes of my SQS message.

However, when I call the API Gateway endpoint via Postman, the request still goes through API Gateway > SQS > Lambda, but there are no message attributes.

Does anyone know why there could be this difference between the test functionality and calling the endpoint?

Share Improve this question asked Feb 4 at 11:41 gweilogweilo 634 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

If it works in the Test tab but not through Postman, it could be an issue with how API Gateway handles the request when it comes from an external client. Check if Postman isn't stripping headers, cause sometimes required headers get lost.

One more tip, try logging $context.requestId in API Gateway logs to confirm it's being captured correctly.

If nothing works, maybe adding CloudWatch logging at different points in the flow could help figure out where the attributes are getting lost.

发布评论

评论列表(0)

  1. 暂无评论