AWS DynamoDB table has :
- Client (Primary Key),
- folder_location (non-key attribute),
- script_name (non-key attribute)
I want to retrieve records using Client and folder_location attributes using BatchGetItemRequest
.
But getting below error:
Failed to retrieve items.com.amazonaws.services.dynamodbv2.model.AmazonDynamoDBException: The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
Is there a way to do with BatchGetItemRequest
only ?
CodePudding user response:
You could instead use a Query or Scan operation and specify a Filter Expression to limit results based on the folder_location
.
To use BatchGetItemRequest
you must provide the key, per https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchGetItem.html:
The BatchGetItem operation returns the attributes of one or more items from one or more tables. You identify requested items by primary key.
Keys - An array of primary key attribute values that define specific items in the table. For each primary key, you must provide all of the key attributes. For example, with a simple primary key, you only need to provide the partition key value. For a composite key, you must provide both the partition key value and the sort key value.
I recommend you double check that the key you are providing matches the key defined in the table (name and data type). If so, then try one of those other options with a FilterExpression.