I created a simple AWS Lambda function to add two numbers using python 3.6. It reads val1
& val2
values in json body. When I tested lambda function in lambda console it works fine. But when I call lambda function by a POST request through AWS API gateway using POSTMAN, it responses with "message": "Internal server error" (502 Bad Gateway). Can anyone help me with this error?
Lambda function
import json
def lambda_handler(event, context):
# TODO implement
val1 = int(event['val1'])
val2 = int(event['val2'])
val3 = val1 + val2
return {
'statusCode': 200,
'headers': {'Content-Type': 'application/json'},
'body': json.dumps(val3)
}
JSON body
{
"val1": "3",
"val2": "5"
}