Kern Elliott
Kern Elliott

Reputation: 1659

Cannot send POST data to Lambda

I am trying to send data to my lambda function however the function is not getting my data, the event variable is empty. I am not getting any errors and when I test the function in my API Gateway it works fine. So I am not sure what is happening. My code for sending data to Lambda is below.

var options = { 
    method: 'POST', 
    url: 'correct api url', 
    contentType: "application/json",
    dataType: "json",
    data: s
}

for data: s within my console looks like this data: '{"article_url":"a url here"}'

Any idea what the problem is?

Upvotes: 0

Views: 3207

Answers (1)

SteamDev
SteamDev

Reputation: 4414

In the "Integration Request" configuration, make sure you've checked the "Use Lambda Proxy integration" checkbox.

And make sure your output matches the schema defined here to avoid errors:

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

{
    "isBase64Encoded": true|false,
    "statusCode": httpStatusCode,
    "headers": { "headerName": "headerValue", ... },
    "body": "..."
}

Upvotes: 0

Related Questions