Python 将json文件传递给无服务器lambda

Python 将json文件传递给无服务器lambda,python,amazon-web-services,curl,aws-lambda,serverless,Python,Amazon Web Services,Curl,Aws Lambda,Serverless,我创建了一个简单的api,它从json文件(作为输入传递)读取一个密钥,并检查数据库中是否存在密钥 如果我在本地测试它 serverless invoke local --function getVin --path input/input_212.json 工作 一旦部署到AWS上,如何使用curl进行测试 我正在尝试 curl --request GET 'https://xxxx.execute-api.us-east-1.amazonaws.com/dev/vin' --header

我创建了一个简单的api,它从json文件(作为输入传递)读取一个密钥,并检查数据库中是否存在密钥 如果我在本地测试它

 serverless invoke local --function getVin --path input/input_212.json
工作

一旦部署到AWS上,如何使用curl进行测试

我正在尝试

curl --request GET 'https://xxxx.execute-api.us-east-1.amazonaws.com/dev/vin' --header 'content-type: text/plain' --data-raw  @input.json

但不适用于此错误

curl -H "Content-Type: application/json" -X GET -d '{
"CustomerId": 213,
"VIN": "WDBJF65J1YB039213"
}' https://xxxxx.execute-api.us-east-1.amazonaws.com/dev/vin
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: iMPlncZFM2NQcVwotAWQmbear6akaktsKVTyin6Mmqcd7T5z0_Vijw==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>%

您确定这是GET请求吗?您正在将JSON数据传递给API,这意味着您必须确保在CURL请求、已编写的无服务器应用程序以及无服务器配置文件中使用POST请求。一旦您了解了这一点,下面的CURL请求应该可以工作:

curl --request POST \
  --url https://xxxxx.execute-api.us-east-1.amazonaws.com/dev/vin \
  --header 'Content-Type: application/json' \
  --data '{
    "CustomerId": 213,
    "VIN": "WDBJF65J1YB039213"
}'

但不起作用
返回什么错误?添加错误消息该方法作为get实现,json是一个输入文件,用于检查json中的数据是否存储在数据库中。我还有一篇帖子,在那里我仍然传递一个json,然后将其存储在数据库中。我的问题是如何从终端呼叫它
{
    "key1": 1,
    "key2": "abcdefg"
}
curl --request POST \
  --url https://xxxxx.execute-api.us-east-1.amazonaws.com/dev/vin \
  --header 'Content-Type: application/json' \
  --data '{
    "CustomerId": 213,
    "VIN": "WDBJF65J1YB039213"
}'