I have an API that is connected to a lambda function that has queryStringParameters. On the function end I have
VARIABLE = event['queryStringParameters']['variable']
When I deploy my API and try to use it "api_url"?variable=something,
I get {"message": "Internal server error"}
.
In Cloudwatch I get:
[ERROR] KeyError: 'queryStringParameters'
Traceback (most recent call last):
File "/var/task/index.py", line 217, in handler
VARIABLE = event['queryStringParameters']['variable']
To help troubleshoot I print the event. In Cloudwatch it does, and it appears as "{}", so pretty much as empty.
When I test the function in the console I use the event:
{ "queryStringParameters": {"variable": "T"}}
and the function works just fine.
I've made APIs that are connected to lambda functions before almost identical to this and have had no problem. I'm stumped. Any advice is appreciated.