Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway accept Content-type: application/xml

I've got a question about AWS API Gateway..

I want to process an other companies API into my own dynamoDB in AWS. They can only POST an XML formatted to my API. My setup is API Gateway -> Lambda -> DynamoDB.

But how can do set up a API Gateway POST in such a way that i accepts the XML posted by them?

Link to their XML Post setup (it's just the uplink data): http://zakelijke-community.kpn.com/t5/Data/Application-data-API/ta-p/4768

like image 504
Rick Pasveer Avatar asked May 11 '16 13:05

Rick Pasveer


1 Answers

You can define a request mapping template for "application/xml" which will be triggered when the client sends a "Content-Type" header of "application/xml".

While API Gateway doesn't yet offer first-class support for XML, you can simply send the XML payload to Lambda in a JSON string field:

{ 
   "bodyXml" : "$input.body"
}

In your Lambda function, you can use your XML parsing library of choice to process the XML.

Hope this helps, Ryan

like image 158
RyanG Avatar answered Nov 15 '22 06:11

RyanG