An API Gateway endpoint integrated with a Lambda function returns the error: 'Method completed with status: 502'. What is the most likely fix?
Choose an answer
Tap an option to check your answer.
Correct answer: Modify the Lambda function so its response is formatted in the way API Gateway expects..
Why this is the answer
A 502 Bad Gateway error from API Gateway, when integrated with Lambda, typically indicates that API Gateway received an invalid response from the Lambda function. API Gateway expects a specific JSON format for the Lambda function's output, including statusCode, headers, and body. If the Lambda function's response does not adhere to this structure, API Gateway cannot properly process it and returns a 502 error. Changing to HTTPS or modifying the payload sent to API Gateway are unlikely to resolve a 502 error originating from the Lambda integration, as these relate to the client-API Gateway interaction or input, not the Lambda's output. Similarly, authorization issues usually result in 401 or 403 errors, not a 502.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed