Search code examples
jsonamazon-web-servicesaws-api-gatewayamazon-sqsaws-sqs-fifo

After Changing the Body content , AWS SQS is not saving the event and Error of access denied comes up


Using the Postman, I am trying to save an event in the SQS, it is all working fine with just simple JSONas below,

{
  "subscriptionId": "6d000ba7-9bcb-3e2f-bf2e-e960026f000e",
  "notificationId": 6,
  "id": "e8ee798d-c888-4fdd-666a-626627da0f73",
  "eventType": "workitem.created",
  "publisherId": "tfs"

}

but when I add the below message:.. content in the the JOSN body it comes up with the access Denied error in response in Postman(screenshot attached below). cant get my head around what is the reason it reject just because I change something in the body.

-Any pointers please if I am missing something here?

{
  "subscriptionId": "6d000ba7-9bcb-4e2f-bf2e-e960046f000e",
  "notificationId": 6,
  "id": "e0ee798d-c888-4fdd-666a-976627da0f73",
  "eventType": "workitem.created",
  "publisherId": "tfs",
  "message": {
    "text": "Issue #17 (sdgdfsgfdg) created by Umair Ashraf\r\n(https://dev.azure.com/Umair0ashraf777/web/wi.aspx?pcguid=a6844a4c-f27f-428a-8051-342343b5fa34&id=19)",
    "html": "<a href=\"https://dev.azure.com/Umair0ashraf777/web/wi.aspx?pcguid=a6844a4c-f27f-428a-8051-342343b5fa34&amp;id=17\">Issue #17</a> (sdgdfsgfdg) created by Umair Ashraf",
    "markdown": "[Issue #17](https://dev.azure.com/Umaira0shraf777/web/wi.aspx?pcguid=a6844a4c-f27f-428a-8051-342343b5fa34&id=17) (sdgdfsgfdg) created by Umair Ashraf"
  }
}

The below error appears after I add the message and its value in the Body in Postman,

enter image description here

The APIGateway is configured as below to save the messages in the SQS enter image description here


Solution

  • It was an encoding issue! so need to encode the body before it is sent to the SQS queue as below,

    So we need to go to the API and then go to the Integration request and set the mapping template as below,

    Action= SendMessage&MessageBody= $util.urlENcode($input.body)
    

    enter image description here

    Note: Before I was using without encoding the body as below and was working only for simple JSON stuff...

    Action= SendMessage&MessageBody=$input.body