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,260 points
5,600 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
• 58,020 points

Related Questions In AWS

0 votes
1 answer
0 votes
1 answer

How to get API Gateway function output from a step-function

First of all the step functions executes ...READ MORE

answered Dec 27, 2018 in AWS by Archana
• 5,640 points
4,249 views
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
• 58,020 points
10,141 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,670 points
8,769 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP