skip to Main Content

I have integrated AWS API Gateway to SQS queue and it give response in format

{
"SendMessageResponse": {
    "ResponseMetadata": {
        "RequestId": "acfa1737-7d53-5aeb-8c75-482a8f8eab1b"
    },
    "SendMessageResult": {
        "MD5OfMessageAttributes": null,
        "MD5OfMessageBody": "ed1dbe6fa17bf45a3d20ea7be2661bfb",
        "MD5OfMessageSystemAttributes": null,
        "MessageId": "e41f656e-1e2a-4269-a0e0-2016d9406ac8",
        "SequenceNumber": null
    }
}

}

how can I customize the integraion that response will look like

{           
   "RequestId": "e41f656e-1e2a-4269-a0e0-2016d9406ac8",
   "Message": "Request Accepted"
}

where RequestId is MessageId from SQS Queue
and the Message is some custom acknowledgment message

2

Answers


  1. Chosen as BEST ANSWER

    Found a solution to use mapping response templates

    enter image description here


  2. The quickest way to implement this is to use a custom ResponseTemplate in API Gateway Integration response. Something like this.

           {
            "RequestId": $input.json('$.SendMessageResponse.ResponseMetadata.RequestId'),
            "Message": "Request Accepted"
           }
    

    Also don’t forget to re-deploy the API Gateway after updating the ResponseTemplate mapping.

    API Gateway Response Template

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search