使用CLI时如何解决AWS DynamoDB中的(ValidationException)问题?

问题描述 投票:0回答:1

我只是在CLI中学习AWS DynamoDB。我专门使用命令执行put-itemaws dynamodb put-item --table-name new --item file://item.json。我已经成功配置了IAM凭据,并且还可以使用以下方式获取回复:aws dynamodb list-tables

{ "TableNames": [ "new", "test" ] }

错误:

Validation Error

我特别是这个错误:An error occurred (ValidationException) when calling the PutItem operation: One or more parameter values were invalid: Missing the key newid in the item

任何人都可以指导我如何摆脱这个错误并解决此错误吗?

amazon-web-services aws-lambda amazon-dynamodb put dynamo-local
1个回答
0
投票

好吧,我是问这个问题的人,感谢@ krishna_mee2004提出了我的问题的提示。主要问题是我已将分区键指定为test_id,而我正在使用它作为user_id

我以前在item.json中的格式是

    {
    "user_id":{"S":"123add"},
    "ForumName": {"S": "Amazon DynamoDB"},
    "Subject": {"S": "New discussion thread"},
    "Message": {"S": "First post in this thread"},
    "LastPostedBy": {"S": "[email protected]"},
    "LastPostDateTime": {"S": "201603190422"}
}

但是我只是将user_id替换为test_id

   {
    "test_id":{"S":"123add"},
    "ForumName": {"S": "Amazon DynamoDB"},
    "Subject": {"S": "New discussion thread"},
    "Message": {"S": "First post in this thread"},
    "LastPostedBy": {"S": "[email protected]"},
    "LastPostDateTime": {"S": "201603190422"}
}

这是我的AWS DynamoDB表的实际分区键,可以正常工作:

i已成功创建表列表:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.