Reputation: 1258
I have a POST method in which will be used to add comments to my RDS using Lambda. i am trying to connect it all up using the AWS API, however can't figure out how to do so.
How can I read the body of my HTTP request (specifically the comment variable) into my lambda function.
{"body" : $input.json('$')}
Will that take the whole POST body and make it available in the Lambda function?
Upvotes: 2
Views: 1340
Reputation: 17
I have added few line of code in my lambda function to get all the header,body data.
Step-:
{
"body" : $input.json('$'),
"headers": {
#foreach($header in $input.params().header.keySet())
"$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end
#end
},
"method": "$context.httpMethod",
"params": {
#foreach($param in $input.params().path.keySet())
"$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end
#end
},
"query": {
#foreach($queryParam in $input.params().querystring.keySet())
"$queryParam": "$util.escapeJavaScript($input.params().querystring.get($queryParam))" #if($foreach.hasNext),#end
#end
}
}
Now in our event parameter you can get body data as event.body and header data as event.headers
Upvotes: 1