The payload of the POST request is in xml format, so as far as I know, we need to use a mapping template to wrap the payload in a json object. When we All of these are very useful when specifying the content-type as a setting type in the Integration Request section.
Now my understanding is that if the content-type is not specified in the request header, then it should default Is’application/json’ and executes the mapping template associated with the type. In our case, it behaves as if the mapping template is ignored, and the latter returns the following error:
{” Type”: “User”, “message”: “Unable to parse the request body as json.”}
Please note that the request will be sent to AWS Lambda for processing.
Any Ideas how can we achieve this goal?
Edit: I have confirmed that the default is’application/json’, in case if Content-Type is not set in the header. In that case, I assume that what I encountered is an error.
p>
In fact, this will parse the main The responsibility is transferred back to the lambda function. Your event object will now contain a body string-so regardless of the title, api-gw will pass the body to your function for processing. This will allow you to parse the body as XML, even if the content type The header is missing/invalid.
I am working for the data provider of my project, unfortunately it does not comply with any standards, so there is no content specified in the header of the request Type. Actually it is specified, but using a different key and then the content type.
The payload of the POST request is in xml format, so as far as I know, we need to use the mapping template The payload is wrapped in a json object. When we specify the content-type as a setting type in the Integration Request section, all of these are very useful.
Now my understanding is that if in the request header If the content-type is not specified, then it should default to’application/json’ and execute the mapping template associated with that type. In our case, it behaves as if the mapping template is ignored, and the latter returns the following error :
{“Type”:”User”,”message”:”The request body cannot be parsed as json.”}
Please note that the request will be sent to AWS Lambda for processing Processing.
Any ideas how we can achieve this goal?
Edit: I have confirmed that the default is’application/json’, in case if Content-Type is not set in the header. In that case, I assume that I encountered an error.
p>
If you don’t rely much on the mapping template, you can always use lambda proxy integration: http://docs.aws.amazon.com/apigateway/latest/developerguide/ api-gateway-create-api-as-simple-proxy-for-lambda.html
In fact, this transfers the responsibility of parsing the principal back to the lambda function. Your event object will now Include a body string-so regardless of the title, api-gw will pass the body to your function for processing. This will allow you to parse the body as XML even if the content type header is missing/invalid.
p>