It appears that when I send a body with a POST request my template mapping is getting overwritten by the payload.
I have an API gateway resource invoking a Lambda function. The Lambda function is simple, it just echoes what it receives.
exports.handler = function(event, context) {
context.succeed({event: event});
};
This Lambda function, called echo, is invoking the Lambda function through a POST. The POST method has an integration request mapping template (which is straight from the docs):
{
"name" : "$input.params('name')",
"body" : $input.json('$')
}
When I make a request WITHOUT a body I get back the response I expect:
curl -XPOST https://foo.execute-api.us-east-1.amazonaws.com/test/echo?name=foo
{"event":{"name":"foo","body":{}}
However, when I make a request WITH a body the template mapping no longer works:
curl -XPOST https://foo.execute-api.us-east-1.amazonaws.com/test/echo?name=foo -d '{"text": "Say goodbye to your template mapping"}'
{"event":{"text":"Say goodbye to your template mapping"}
How can I ensure my template mapping applies when a body is present in the request?