This is a typical issue while Lambda sitting behind API gateway. I've googled almost all the posts but still can't not figure out why it fails.
I've read the instruction on what the response should be look like
https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format
It is looking for
{
"isBase64Encoded": true|false,
"statusCode": httpStatusCode,
"headers": { "headerName": "headerValue", ... },
"multiValueHeaders": { "headerName": ["headerValue", "headerValue2", ...], ... },
"body": "..."
}
Here is the log of my test from API gateway console (I have double checked make sure the name of fields are exactly the same)
Thu Mar 19 10:07:58 UTC 2020 : Endpoint response body before transformations: "{\"statusCode\":200,\"body\":\"RESULTS\",\"isBase64Encoded\":false}"
Thu Mar 19 10:07:58 UTC 2020 : Execution failed due to configuration error: Malformed Lambda proxy response
Thu Mar 19 10:07:58 UTC 2020 : Method completed with status: 502
Can anyone help?
EDIT
I've removed "body" from response and still get the same error. The following is the actual log
Thu Mar 19 23:29:54 UTC 2020 : Received response. Status: 200, Integration latency: 24 ms
Thu Mar 19 23:29:54 UTC 2020 : Endpoint response headers: {Date=Thu, 19 Mar 2020 23:29:54 GMT, Content-Type=application/json, Content-Length=48, Connection=keep-alive, x-amzn-RequestId=f2c2c752-a5e0-45e4-9ff0-d91826b51c7b, x-amzn-Remapped-Content-Length=0, X-Amz-Executed-Version=$LATEST, X-Amzn-Trace-Id=root=1-5e740072-46cee9045a56e04b8023816d;sampled=0}
Thu Mar 19 23:29:54 UTC 2020 : Endpoint response body before transformations: "{\"statusCode\":200,\"isBase64Encoded\":false}"
Thu Mar 19 23:29:54 UTC 2020 : Execution failed due to configuration error: Malformed Lambda proxy response
Thu Mar 19 23:29:54 UTC 2020 : Method completed with status: 502
The actual JSON response catptured in java app & lambda is
{"statusCode":200,"isBase64Encoded":false}