Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API-Gateway GET Method Parameter Mapping

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

like image 800
3uPh0riC Avatar asked Mar 04 '26 20:03

3uPh0riC


1 Answers

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')"
}
like image 121
Ka Hou Ieong Avatar answered Mar 07 '26 11:03

Ka Hou Ieong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!