Can we create a Rest URL like below in API Gateway?
[GET] /employees?id=1&id=2&id=3&id=4
I do not find a way to send id array and get that array into a lambda (python) function
Step 1: Open API Gateway Management Console and choose the API. Step 2: Choose the resources. Choose the configured HTTP method. Step 3: Choose the Integration Request. Step 4: Select HTTP or Lambda as integration type.
To configure a REST API to pass query string parameters to a backend Lambda function, use a Lambda custom integration. To pass query string parameters to an HTTP endpoint, use an HTTP custom integration. Important: Make sure that the input data is supplied as the integration request payload.
The guide demonstrates how to accept the array as the query parameter in API Gateway proxy and non-proxy Lambda integrations In the non-proxy lambda integration, it is required to map the query parameter in the request mapping template to the lambda handler model property. Suppose our DTO has form of
I need my Amazon API Gateway REST API to pass query string parameters to a backend AWS Lambda function and an HTTP endpoint. How can I do that? To configure a REST API to pass query string parameters to a backend Lambda function, use a Lambda custom integration. To pass query string parameters to an HTTP endpoint, use an HTTP custom integration.
AWS API events have a "multiValueQueryStringParameters" field which can be used instead of "queryStringParameters". It will contain value arrays for all parameters:
idArray = event["multiValueQueryStringParameters"]["id"]
this is very late but I had the same issue and found the problem:
From AWS API Gateway Reference:
When a query parameter is a list type, its value must be a string of comma-separated items. For example, GET /restapis/restapi_id/deployments/deployment_id?embed=apisummary,sdksummary.
Amazon API Gateway does not support nested query parameters of the form: GET /team?user[id]=usrid on a method request. You could work around this limitation by passing an encoded map as a single parameter and serializing it as part of a mapping template or in your back-end integration.
So a fix you could use is restructuring your request such that:
[GET] /employees?id=1,2,3,4
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With