2 Answers
- Newest
- Most votes
- Most comments
0
You should check what the event structure is when you get it from API Gateway and write your code accordingly. I assume that your payload is embedded in a "body" attribute, that your code doesn't honor. Print the event object as the first line in the handler and then make sure to reference the keys as needed.
Relevant content
- Accepted Answerasked 9 months ago
- Accepted Answerasked 5 years ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
Hi Uri, Thanks for responding. For now, I have made an open API which doesnt require any keys, and using the Test event "{"key1": "value1"}" in Lambda Test environment as well as the API Gateway. The Lambda Test environment is working perfectly fine, And the API Gateway also Invokes the Lambda function if i do not use df=event['key1'] in the code. Whenever i use this line, it throws a key error. Basically, the event is getting considered NULL whenever I invoke the Lambda function through external server
It depends how you configured your API Gateway. The recommended way is to use Lambda proxy integration, and then you will get an event that contains the payload in the "body" attribute. If you did not set a proxy integration, you should create a mapping template to build the event that will be sent to Lambda.