DVA-C02 · Question #438
A developer is building an application integrating an Amazon API Gateway with an AWS Lambda function. When calling the API, the developer receives the following error: Wed Nov 08 01:13:00 UTC 2017 : M
The correct answer is C. Change the format of the Lambda function response to the API call.. A 502 Bad Gateway error from API Gateway means the backend (Lambda) returned a response that API Gateway could not parse - specifically, Lambda must return a properly structured JSON object with statusCode, headers, and body fields; any deviation causes this error. A is wrong bec
Question
A developer is building an application integrating an Amazon API Gateway with an AWS Lambda function. When calling the API, the developer receives the following error:
Wed Nov 08 01:13:00 UTC 2017 : Method completed with status: 502 What should the developer do to resolve the error?
Options
- AChange the HTTP endpoint of the API to an HTTPS endpoint.
- BChange the format of the payload sent to the API Gateway.
- CChange the format of the Lambda function response to the API call.
- DChange the authorization header in the API call to access the Lambda function.
How the community answered
(64 responses)- A8% (5)
- B3% (2)
- C84% (54)
- D5% (3)
Explanation
A 502 Bad Gateway error from API Gateway means the backend (Lambda) returned a response that API Gateway could not parse - specifically, Lambda must return a properly structured JSON object with statusCode, headers, and body fields; any deviation causes this error. A is wrong because HTTP/HTTPS is irrelevant to a 502 - that would affect connectivity, not response parsing. B is wrong because the payload sent to the API doesn't cause a 502; the problem is in the response coming back from Lambda. D is wrong because an auth failure would produce a 401/403, not a 502.
Memory tip: Think of 502 as "Lambda talked back in a language API Gateway didn't understand." If Lambda returns plain text, a raw string, or a malformed object instead of { statusCode, headers, body }, API Gateway throws a 502. Always check the response shape, not the request.
Topics
Community Discussion
No community discussion yet for this question.