2
votes

I have a specific issue on my AWS lambda function that I have recently built (in python 3.8). It's supposed to support a post request and put an item from the body of the request into a table in DynamoDB.

My Lambda function looks like this:

enter image description here

When I test using API Gateway it works perfectly and I get what I expect. and the item gets inserted into the table. This is the response on the API-Gateway Test:

enter image description here

Here's my API gateway post method set up:

enter image description here

However, when I use postman and try to post a JSON I get this Key Error: (Note the JSON body of the post is identical).

enter image description here

Any help I get here will be very much appreciated.

Edit: For those who have read the comments below. This is the code I'm using to return the event:

enter image description here

1
print event on both and see the differenceE.Serra
add print(json.dumps(event)) to your lambda and check in CW Logs the outcome.Marcin
In Postman, is Content-Type set to application/json? Is Content-Length calculated when request is sent? Is the body raw json?jarmod
@jarmod Yes to all of thoseuser9888433
So I'm getting: 'Log group does not exist in this account or region.' when trying to access CW logs. The assigned role has a 'AWSLambdaBasicExecutionRole' policy attached to it. The ARN for the lambda seems to be correct under its own permissions.user9888433

1 Answers

1
votes

So I believe I solved the issue. I simply un-ticked the 'use lambda proxy integration' box when setting up the post method in API Gateway. Now I'm receiving the body as the event as I wanted. Thank you for your responses anyway.