Due to Malformed Lambda proxy response my lambda function through API gateway fails

0 votes

Getting a 502 error on AWS lambda

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"}}

Using stringify to 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?

The lambda code i am using is as follows:

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

    console.log(response)

    callback(null, response);

Nov 2, 2018 in AWS by findingbugs
• 3,140 points
273 views

1 answer to this question.

0 votes

You can refer to the following documentation by AWS.

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

answered Nov 2, 2018 by Priyaj
• 56,160 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 56,160 points
1,230 views
0 votes
1 answer
0 votes
2 answers
+1 vote
3 answers

Not able to pass params POST to AWS Lambda from Amazon API Gateway

For this template : application/x-www-form-urlencoded  This line below will ...READ MORE

answered Jun 13, 2018 in AWS by Cloud gunner
• 4,260 points
1,670 views