I am wanting to pass a query parameter from API Gateway into AWS Lambda but I am always receiving null
values.
Here's my Lambda function which I merely want to return the value of http://foo.bar?name=Dan
'use strict';
exports.handle = (context, event, callback) => {
callback(null, event.name);
}
In API Gateway I have done the following:
- Create a Resource
- Create a Method (
GET
) - Selected the correct Lambda function
- Selected my GET method and clicked on
Integration Request
- Selected
Body Mapping Templates
- Set Content-Type to
application/json
- Added
{"name": "$input.params('name')" }
- Save and deploy!
However, when I load up my API the value of event.name
is always null
. Accessing the API is done via ...amazonaws.com/beta/user?name=dan
Edit: I've tried the accepted answer here but after simply returning the event in the callback, I only receive this data:
{
"callbackWaitsForEmptyEventLoop": true,
"logGroupName": "",
"logStreamName": "",
"functionName": "",
"memoryLimitInMB": "",
"functionVersion": "",
"invokeid": "",
"awsRequestId": "",
"invokedFunctionArn": ""
}
I have omitted the values.