6

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?

2
  • Can you post some of your code? Have you tested your API with the same data your sending with 'curl -d etc.'? Commented Jan 7, 2016 at 7:11
  • If you're passing the data correctly, you should be able to access the data in lambda 'event' object that is passed to your lambda handler. You can try logging the contents of the event object in your handler. Commented Jan 7, 2016 at 7:13

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

Comments

0

In order to send HTTP parameters to a lambda function, they need to be sent in the request body via a mapping template.

See this blog post for a simple example of how to do this.

Comments

0

This is another way to do it:

  1. Open API Gateway, select your endpoint and click on Resources

  2. Select Method Request in the settings

    enter image description here

  3. Under the URL Query String Parameters, you can add query string.

    enter image description here

As an example, in my Python lambda function, I can retrieve the query parameter just with the following:

def endpoint(event, context):
    my_parameter = event["queryStringParameters"]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.