To Nha Notes | March 1, 2023, 2:45 p.m.
For API Gateway to handle a Lambda function's response, the function must return output according to the following JSON format:
{
"isBase64Encoded": true|false,
"statusCode": httpStatusCode,
"headers": { "headerName": "headerValue", ... },
"body": "..."
}
https://aws.amazon.com/premiumsupport/knowledge-center/malformed-502-api-gateway/