'Can't access 'event' properties when calling it in Lambda Function in AWS

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



Solution 1:[1]

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.

Solution 2:[2]

def handler(event, context):
  requestObject = ""
  if "requestObject" in event:
      requestObject = event["requestObject"]
  else:
      requestJson = json.loads(event["body"])
      if "requestObject" in requestJson:
          serialNumber = requestJson["requestObject"]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user9888433
Solution 2 kellen kuo