AWS Lambda:参数验证失败

时间:2018-12-15 08:08:42

标签: parameters aws-lambda amazon-dynamodb http-method

我正在尝试运行以下代码以通过POST方法写入dynamodb,但出现错误:

{
    "httpMethod":"POST",
    "body": {
        "TableName":"LamdaTest",
        "Item":{
            "ID":"1",
            "Name":"Foobar"

        }
    }
}

错误消息:

Parameter validation failed: Invalid type for parameter Item.ID, value: 1, type: <class 'str'>, valid types: <class 'dict'>\nInvalid type for parameter Item.Name, value: Foobar, type: <class 'str'>, valid types: <class 'dict'>",

1 个答案:

答案 0 :(得分:0)

尝试像这样将其作为字典传递(来自docs):

{
    "httpMethod":"POST",
    "body": {
        TableName="LamdaTest",
        Item={
            "ID": {"N":"1"},
            "Name": {"S":"Foobar"}
        }
    }
}