I followed the example from here to set up a sample AWS Lambda function: http://docs.aws.amazon.com/lambda/latest/dg/get-started-step4-optional.html.
Then, I created an HTTP GET endpoint via AWS API Gateway. I can access the endpoint but I don't know how to pass that int myCount
as a parameter.
I tried ?myCount=3
as a GET parameter but that didn't work.
Any help?
Short description. To configure a REST API to pass query string parameters to a backend Lambda function, use a Lambda custom integration. To pass query string parameters to an HTTP endpoint, use an HTTP custom integration. Important:Make sure that the input data is supplied as the integration request payload.
To pass Api Gateway Querystring parameters to a lambda function, using non-proxy integration, you have to: Open the AWS Api Gateway console and click on your API's name. In the Resources tab, click on the specific HTTP method. Click on Method Request and expand the URL Query String Parameters section.
A Lambda integration maps a path and HTTP method combination to a Lambda function. You can configure API Gateway to pass the body of the HTTP request as-is (custom integration), or to encapsulate the request body in a document that includes all of the request information including headers, resource, path, and method.
You need to setup a mapping template in API Gateway. If you know the name of your parameters ahead of time your template could look like this:
{
"myCount": "$input.params('myCount')",
"myUserId": "$input.params('myUserId')"
}
Where each $input.params('...')
will get evaluated and the value in your query string will be put in its place when the event is passed to Lambda.
This is pretty much a duplicate of passing query params for aws lambda function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With