I am using Amazon API Gateway to invoke a lambda function. I am testing a get request with the following as my query string earlyDate="12-01-21"&laterDate="12-03-21".
I currently have my lambda function returning the event that gets passed:
def lambda_handler(event, context):
return {
"statusCode": 200,
"body": json.dumps(event)
}
This works as expected. When I test my API gateway I get a response which includes
"queryStringParameters": {
"earlyDate": "12-01-21",
"laterDate": "12-03-21"
},
"multiValueQueryStringParameters": {
"earlyDate": [
"12-01-21"
],
"laterDate": [
"12-03-21"
]
},
This indicates I should be able to access these query parameters at event.queryStringParameters. However when I change my lambda function to return those:
def lambda_handler(event, context):
return {
"statusCode": 200,
"body": json.dumps(event.queryStringParameters)
}
The result is a 502 error.
How do I access the query string parameters passed in from my API Gateway?