Cannot send POST data to Lambda

久未见 提交于 2019-12-24 20:48:47

问题


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?


回答1:


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


来源:https://stackoverflow.com/questions/45981625/cannot-send-post-data-to-lambda

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!