-1

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 ?

Maurice
  • 11,482
  • 2
  • 25
  • 45
Sri Durga
  • 19
  • 1
  • 9
  • 1
    Can you share some details about your BatchGetItemRequest? You can retrieve multiple items by specifying the primary key. – Tobias Geiselmann Dec 15 '21 at 13:05
  • 1
    Does your table have a partition and sort key (compound primary key) or is client really the only partition/primary key? – Maurice Dec 15 '21 at 13:14
  • Client is the only primary key. But I need details in combination of client and folder_location. Can it happen with BatchGetItemRequest ? – Sri Durga Dec 15 '21 at 14:43

1 Answers1

2

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.

Shawn
  • 8,374
  • 5
  • 37
  • 60