aws apigateway lambda always return 502

Question:

I have created aws apigateway lambda integration for my proxy server. When i am making get request to the gateway, the request is successfully going through. The lambda function also executes successfully and writes response in outputstream with statusCode as 200. But apigateway always returns 502.

Snippet of handleRequest():

Am i missing anything ?

Answer:

502 errors with Lambda usuaully indicate that you are using the Lambda proxy method and not generating the proper JSON response. Make sure your response adheres to the appropriate format.

If you are still having problems, please share a sample JSON generated by your Lambda function.

Leave a Reply