AWS API Gateway accept Content-type: application/x

2020-07-22 07:58发布

问题:

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

回答1:

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