3
votes

I use API-Gateway to map rest requests to some Lambda functions. It works fine for post methods, where i send my information in the body as JSON and access it in the lambda like so

module.exports.handler = function(event, context, cb) {
   var email = event.email;
   var name = event.name;
}

Now i wanted to create a GET, with query strings. On the request side on API-Gateway its fine you can select the query string names, but for the life of me I cant figure out what to do on the Integration Request side. How do i get my query strings into my lambda so that i can access them like above. Or are they accessed differently.

I went through the docs, and still dont understand it. You would think this is like the most basic use case and they have an example, but no.

Please can somebody help me

Thanks

2
I agree, their API-Gateway documentation is incomplete - blueskin

2 Answers

4
votes

You have to create method request parameters for your query string parameters, then you need to create a mapping template to map your query string parameters to the integration request body.

The mapping template will be something like this,

{
    "email": "$input.params('email')",
    "name": "$input.params('name')"
}
0
votes

In order to get query string parameters in AWS lambda, you'll need to map those parameters to attributes on the event object. Step 3 in this AWS Guide illustrates how to add them via the API Gateway console.