1

I have deployed AWS stack with a Lambda function and an API gateway. After deployment I tested Lambda function independently and it works fine but when I invoke it using AWS API Gateway, it fails with `

Internal Error: 502

I looked at cloudwatch logs and it says

Endpoint response body before transformations: null

I am returning my response from Lambda (Python 3.6) in following way -

body = {
        "message": "Success!!"
    }

response = {
    "statusCode": 200,
    "headers": {
        "content-type": "application/json"
    },
    "body": json.dumps(body),
    "isBase64Encoded": False,
}
return response

1 Answer 1

2

Ok, I found the problem. Actually the code is correct. I made few changes and took the above code outside handler. So my handler was calling this new function and it was returning response to handler but I missed to return the received response again from handler to API gateway.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.