amazon web services - Cannot delete item from DynamoDB table (java) -


i've been attempting delete item table in dynamodb through java code, every attempt i've made results in same error:

com.amazonaws.amazonserviceexception: provided key element not match schema (service: amazondynamodbv2; status code: 400; error code: validationexception;

my current attempt simple , looks 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 table name, credentials have been verified correct, , cognitoid actual id of item i'm trying delete. table in question has cognitoid primary key , don't understand why deletion isn't matching schema. table has sort key, or range key (i'm not sure because documentation quite vague). i've been referring documentation here: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workingwithtables.html#workingwithtables.primary.key

did have sort key while creating table? if so, have specify sort key have composite key on table. having sort key means have multiple records same primary key, sort key must unique

http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/workingwithtables.html#workingwithtables.primary.key

the sort key may referred range or range key in aws dynamo db documentation , console.

so delete item like

deleteitemspec itemspec = new deleteitemspec().withprimarykey("cognitoid", "my_id", "sortkeyfield", "sort_key_id"); deleteitemoutcome outcome = table.deleteitem(itemspec); 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -