I have this python lambda function

```
import json

def lambda_handler(event, context):

    post_user = ""
    post_user = event["user"]
    print(post_user)        

    return {
        "statusCode": 200,
        "headers": {"Content-Type": "application/json"},
        "body": True
        }

```

This works as expected when I run a test within the lambda IDE. The test is configured to pass:

> 
> { "user": "JOHN", "pwd": "pwd1" }
> 
> 
> 

but when I run a test using the API Gateway, I get this error:

> 
> Mon Mar 25 20:47:29 UTC 2019 : Endpoint response body before
>  transformations: {"errorMessage": "'user'", "errorType": "KeyError",
>  "stackTrace": [" File \"/var/task/lambda\_function.py\", line 6, in
>  lambda\_handler\n post\_user = event[\"user\"]\n"]} Mon Mar 25
>  20:47:29 UTC 2019 : Lambda execution failed with status 200 due to
>  customer function error: 'user'. Lambda request id:
>  f7955f74-e608-4b10-b216-4e4acf682307 Mon Mar 25 20:47:29 UTC 2019 :
>  Method completed with status: 502
> 
> 
> 

I have defined the API gateway test as follows:
[![enter image description here](https://i.stack.imgur.com/oXGqe.png)](https://i.stack.imgur.com/oXGqe.png)