Reputation: 11
I have a lambda function which works correctly when I test in the AWS Lambda dashboard, however any json data I post to the function appears to be ignored.
If I test with curl:
curl -X POST -H "Content-Type: application/json" -d '{ "email":"[email protected]", "fullname":"Mr Tester", "address":"1 Street" }' https://API.Gateway.url
In the lambda function code using
exports.handler = function(event, context, callback) {..}
event.email is always null.
Upvotes: 1
Views: 1190
Reputation: 2132
You need to create a entry in your apigateway configuration, under resources, select post method -> integration request , under body mapping templates. you can add a application/json content type and add a template for matching your request body json.
The template can be generic like given below or can be designed to suit your parameters.
{
"body" : $input.json('$')
}
Refer this for further information : Cannot send POST data to Lambda
Upvotes: 0