【问题标题】:Dynamodb getBatchItem ValidationExceptionDynamodb getBatchItem ValidationException
【发布时间】:2015-08-12 05:40:08
【问题描述】:

在 dynamodb 表上运行 batchGetItem 函数时出现 ValidationException。我在键列表下同时给出哈希键和范围键。这是请求和响应。

请求:

var params = {"RequestItems":{"table":{"Keys":[{"hash_key":{"S":"xx.xxx.xxx.xxx"}},{"range_key":{"S":"xxxxx"}}]}}};

dynamodb.batchGetItem(params,function(err, res) {if(err) {console.log(err)}else{console.log(res);}});

回复:

{ [ValidationException: The provided key element does not match the schema]
  message: 'The provided key element does not match the schema',
  code: 'ValidationException',
  time: Tue Jun 30 2015 17:34:07 GMT-0400 (EDT),
  statusCode: 400,
  retryable: false,
  retryDelay: 0 }

【问题讨论】:

    标签: node.js amazon-dynamodb


    【解决方案1】:

    看起来 AWS Node JS 有一个错误,我们不需要提及键的数据类型。

    我试过了,效果很好

    {
    "RequestItems":{
      "<TableName>":{
        "Keys":[
             {"<HashKeyName>":"<HashKeyValue1>", "<RangeKeyName>":"<RangeKeyValue2>"},
             {"<HashKeyName>":"<HashKeyValue2>", "<RangeKeyName>":"<RangeKeyValue2>"}
            ]
        }
      }
    }
    

    【讨论】:

      【解决方案2】:

      当您的表的架构与您提供的键的键架构不匹配时,您会收到此错误。您提供了一个带有 Hash=String 和 Range=String 的键。你的表的架构是什么?您可以使用DescribeTable API 来获取表的架构。

      【讨论】:

      • 是的,Hash 和 Range 都是 string 。 AWS 端似乎出现了一些异常行为,我发起了技术支持工单。仍然没有解决方案。
      猜你喜欢
      • 2022-06-13
      • 2017-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-08
      • 2014-10-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多