'AWS HTTP API Gateway integration with SQS - MessageAttribute doesn't work

I've integrated HTTP API Gateway with SQS and have some problem with MessageAttributes. The main goal is to pass parameter in URL, attach it to message attribute and send to SQS.

I've created HTTP API with RouteKey = "$default" with the following RequestParameters:

RequestParameters =
            {
                {"MessageBody", "$request.body"},
                {"QueueUrl", Output.Format($"{config.SqsPath}")},
                {"MessageAttributes", @"{
                  ""SubscriptionId"": {
                  ""DataType"": ""String"",
                  ""StringValue"": ""abc123""                  
                  }
                }"}
            }

for test purpose I've hardcoded value, but at the end I'll use $request.querystring.SubscriptionId

What I have now, is the following:

AWS Console printscreen

It looks good, however all post requests which I made didn't contains any attributes:

CloudWatch printscreen

What have I missed?

Update

I figured out what happened - I had to pass parameters template with invalid format (however, no error was thrown).

Finally I have a working version, message attribute in AWS Console:

{ "SubscriptionId": { "DataType": "String", "StringValue": "${request.querystring.SubscriptionId}" } }

and my integration code:

RequestParameters =
            {
                {"MessageBody", "$request.body"},
                {"QueueUrl", Output.Format($"{config.SqsPath}")},
                {"MessageAttributes", @"{ ""SubscriptionId"": { ""DataType"": ""String"", ""StringValue"": ""${request.querystring.SubscriptionId}"" } }"}
            },


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source