0

I have created an API for SQS(FIFO) and its working fine but its returning Json response but I need XML response.

Below is the Json response which need to be converted before sending to client:

{
"ReceiveMessageResponse": {
"ReceiveMessageResult": {
  "messages": [
    {
      "Attributes": null,
      "Body": "hello",
      "MD5OfBody": "5d41402abc4b2a76b9719d911017c592",
      "MD5OfMessageAttributes": null,
      "MessageAttributes": null,
      "MessageId": "2497c4a7-3a0e-434c-bad8-6cb8d0fd825e",
      "ReceiptHandle": "AQEBQw+v1uUf2ALjbKOea48ifVdeXemCS+qhEGLT2vb+eTRciW803NWUJKVErUqVpuNhmtS5Pkt8USxLZ4OUm4sWJhftLIdyZ29DoT8rBssPjB1gEG7xTohDqzeFsndznIudfE8uY6oQgb1769ICE4bji2DBHqzKAzAic7UhoUjGHw2NLzpE01FiPYnH/f7kR+Z47Wm5XdWFX2wOnzYtmZ1mAsnM0k0EtQG8aqQTQpoDjBx+ep0UsIrdg2r6O+VJfCTnepyDf2rF5kbfTdYRg0ngN32N9ecBq+6vVDpzg1lod/0="
    },
    {
      "Attributes": null,
      "Body": "hi",
      "MD5OfBody": "49f68a5c8493ec2c0bf489821c21fc3b",
      "MD5OfMessageAttributes": null,
      "MessageAttributes": null,
      "MessageId": "06c7a999-8764-45dc-8cf6-b4ad6f6a446a",
      "ReceiptHandle": "AQEBf8Fsh4/+aydDWKpT20XDRCejNAAovF+RVPmg3yVhLCH/R728CqmoU99g13nE+yVneJxrv2zps84SUWGIyZQiCrOyKgkF3faOo4RW3wDWYwF+xb1ahr5B7EItskM1gQhyua+6PiBukQxnrfIcma1ANCngwv+tEe7uUGMblAd/NxvrGkCGHyuyON9xKx5c+V5+546jCgDzMhhqips5Bgy4kh5KSfKpSjJHYXVoa0JBKqDYFm017wxnhDiyi4pSEOdzS7K6L25n6z1rNyPWpTaB0RrHveZCqvO2WWKmoBGoKD8="
    }
  ]
},
"ResponseMetadata": {
  "RequestId": "5969d3d4-90c6-50df-b0ad-87d35b54835b"
}
}
}
Rock
  • 101
  • 3
  • 15
  • 1
    You can create your serverless API with API Gateway + Lambda (Where you can put your transformation code) – Ashan Sep 04 '18 at 05:44
  • ya I can but my requirement is to create as less no of lamda functions as possible – Rock Sep 05 '18 at 08:17
  • 1
    API Gateway alone cannot do the transformation, so you will anyway need a Lambda function. – Ashan Sep 05 '18 at 08:22
  • I get to know about VTL but can't find a proper way to parse json using it. – Rock Sep 05 '18 at 18:46

1 Answers1

0

By default, the API will send a response in JSON format to the client application. In order for the API to be able to send a response to the client in XML format, you will need to add the following HTTP Headers to the "Integration Request":

Accept 'application/xml'

reference