1
votes

I have set up API Gateway endpoint like this:

GET files/{filename}

Therefore, I would call it something like this: https://mydomain/api/files/somefile

I have also a lambda function with Nodejs which is empty:

exports.handler = function(event, context) {

//Retrieve here the param called 'filename' and do something with it

};

How can I get the param passed on the GET request?. I have checked out the event and context objects but I could not find anything helpful.

Thanks!!

1

1 Answers

5
votes

To get path parameters, HTTP header variables (etc) you must create a mapping template.

  1. From the API Gateway console, select your get resource and you should see a panel w/4 boxes.
  2. Click on "Integration Request" (top right box)
  3. Expand "body mapping template" on bottom
  4. Define content type (most likely "application/json")
  5. Try "generate template:method request passthru" to get started
  6. Save
  7. Now try "Test" for your HTTP Get, and hopefully you will see the missing path param, etc.

Good luck.