4

for some reason my AWS lambda returns a 502 error no matter how i change my response.

Sun Mar 25 03:39:12 UTC 2018 : Endpoint response body before transformations: {"status":200,"body":"{\"Items\":[],\"Count\":0,\"ScannedCount\":1}","isBase64Encoded":false,"headers":{"content-type":"application/json"}}

I have made sure to stringify my body and add the status, headers, and isBase64Encodeded properties. I have tried varying the headers and making them empty as well.

Why do i get this error?

here is the lambda code:

    var response = {
        status : 200,
        body : JSON.stringify(data),
        isBase64Encoded : false,
        headers : {"content-type" : "application/json"}
    }

    console.log(response)

    callback(null, response);

1 Answer 1

8

API Gateway expects statusCode, not status.

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html#api-gateway-simple-proxy-for-lambda-output-format

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.