When calling the API, the developer receives the following error:Wed Nov 08 01:13:00 UTC 2017 : Method completed with status: 502What should the developer do to resolve the error?
Change the HTTP endpoint of the API to an HTTPS endpoint.
Change the format of the payload sent to the API Gateway.
Change the format of the Lambda function response to the API call.
Change the authorization header in the API call to access the Lambda function.
Explanations:
The error 502 (Bad Gateway) typically occurs when the API Gateway cannot connect to the backend service, which in this case is the AWS Lambda function. Changing the HTTP endpoint to HTTPS will not resolve the connectivity issue between the API Gateway and the Lambda function.
Changing the format of the payload sent to the API Gateway is not likely to resolve a 502 error. This error indicates a failure in the connection or response from the backend (Lambda), rather than an issue with the request format itself.
A 502 error can occur if the Lambda function does not return the expected response format that the API Gateway is configured to handle. Ensuring that the Lambda function response matches the expected format (such as including the correct status code and headers) can resolve this error.
While authorization issues can lead to errors, they typically result in 403 Forbidden or 401 Unauthorized responses. A 502 Bad Gateway error indicates that the API Gateway is unable to reach the Lambda function, not that authorization is failing. Changing the authorization header will not fix the connectivity problem.