I've been attempting to delete an item from a table in DynamoDB through java code, but every attempt I've made results in the same error:
com.amazonaws.AmazonServiceException: The provided key element does not match the schema (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
My current attempt is very simple and looks like this:
final DynamoDB dynamoDB = new DynamoDB(new AmazonDynamoDBClient(credentials));
Table table =dynamoDB.getTable(tableName);
DeleteItemSpec itemSpec = new DeleteItemSpec().withPrimaryKey("cognitoId", cognitoId);
table.deleteItem(itemSpec);
tablename is simply the table name, the credentials have been verified to be correct, and cognitoId is the actual ID of the item I'm trying to delete. The table in question has cognitoId
as the primary key and I don't understand why the deletion isn't matching the schema. The table also has a sort key, or range key (I'm not sure what it is because the documentation is quite vague). I've been referring to the documentation here:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/WorkingWithTables.html#WorkingWithTables.primary.key
deleteItem(String hashKeyName, Object hashKeyValue)
- Chris Franklin