AWS Lambda and API Gateway response integration issue

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-30 04:37:50

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!