【问题标题】:How to resolve the issue of (ValidationException) in AWS DynamoDB while working with CLI?使用 CLI 时如何解决 AWS DynamoDB 中的 (ValidationException) 问题?
【发布时间】:2019-12-23 14:15:26
【问题描述】:

我刚刚在 CLI 中学习 AWS DynamoDB。我专门使用命令执行put-item aws dynamodb put-item --table-name new --item file://item.json。我已经成功配置了 IAM 凭证,我还可以使用 aws dynamodb list-tables

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

错误:

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

谁能指导我如何摆脱这个并修复这个错误?

【问题讨论】:

  • 你的分区键是什么?
  • @krishna_mee2004 test_id(字符串)
  • @krishna_mee2004 尤里卡。我明白了,谢谢你的提示
  • 如果您需要,可以在 CLI 和大多数 SDK 的 DynamoDB 文档的入门部分中提供相关示例。

标签: amazon-web-services aws-lambda amazon-dynamodb put dynamo-local


【解决方案1】:

好的,我是提出这个问题的人,感谢@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": "fred@example.com"},
    "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": "fred@example.com"},
    "LastPostDateTime": {"S": "201603190422"}
}

这是我的 AWS DynamoDB 表的实际分区键,瞧,它起作用了:

i 成功创建表列表:

【讨论】:

    猜你喜欢
    • 2022-06-13
    • 1970-01-01
    • 2016-04-08
    • 2021-07-15
    • 2021-02-20
    • 1970-01-01
    • 1970-01-01
    • 2020-12-27
    • 2021-02-17
    相关资源
    最近更新 更多