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 Answer 1
To get path parameters, HTTP header variables (etc) you must create a mapping template.
- From the API Gateway console, select your get resource and you should see a panel w/4 boxes.
- Click on "Integration Request" (top right box)
- Expand "body mapping template" on bottom
- Define content type (most likely "application/json")
- Try "generate template:method request passthru" to get started
- Save
- Now try "Test" for your HTTP Get, and hopefully you will see the missing path param, etc.
Good luck.
Comments
Explore related questions
See similar questions with these tags.