Avichal Badaya
Avichal Badaya

Reputation: 3629

Dynamodb getBatchItem ValidationException

Getting ValidationException when I run batchGetItem function on dynamodb table . I am giving both hash key and range key under keys list. Here are request and response .

Request:

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);}});

Response:

{ [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 }

Upvotes: 1

Views: 1488

Answers (2)

user2894145
user2894145

Reputation: 21

Looks like the AWS Node JS has a bug, in that we need not mention the data type for the keys.

I tried this and it worked well

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

Upvotes: 2

Alexander Patrikalakis
Alexander Patrikalakis

Reputation: 5205

You get this error when the schema of your table does not match the key schema of the keys you provided. You provided a key with Hash=String and Range=String. What is the schema of your table? You can use the DescribeTable API to get the schema of your table.

Upvotes: 0

Related Questions