问题
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:
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.
来源:https://stackoverflow.com/questions/54111754/aws-lambda-and-api-gateway-response-integration-issue