2
votes

I'm trying to set up a simple DynamoDB table to store some basic data. I've looked at the sample code provided by Amazon and think I've done everything right, but am receiving the following error when I try and save an item:

"Error: [Error Domain=com.amazonaws.AWSDynamoDBErrorDomain Code=0 "The operation couldn’t be completed. (com.amazonaws.AWSDynamoDBErrorDomain error 0.)" UserInfo=0x7f9c39df9d20 {__type=com.amazon.coral.validate#ValidationException, message=The provided key element does not match the schema}]"

The table has a hash key (string) called "UUID" and a range key (string) called "EmailAddress". No secondary indexes.

The code I'm using is:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

AWSDynamoDBObjectMapper *dynamoDBObjectMapper = [AWSDynamoDBObjectMapper defaultDynamoDBObjectMapper];


EaSLIEmailList *emailListItem = [EaSLIEmailList new];

emailListItem.UUID = [[NSUUID UUID] UUIDString];
emailListItem.EmailAddress = @"[email protected]";

NSMutableArray *tasks = [NSMutableArray array];
[tasks addObject:[dynamoDBObjectMapper save:emailListItem]];

[[BFTask taskForCompletionOfAllTasks:tasks]
 continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task) {
     if (task.error) {
         NSLog(@"Error: [%@]", task.error);
     }

     [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

     return nil;
 }];

Any help would be much appreciated.

Thanks.

1

1 Answers

3
votes

Okay, I've fixed it.

In my AWSDynamoDBObjectModel class I had't fully implemented the AWSDynamoDBModeling protocol but didn't receive a compile error.

For the table I described above, you need to implement dynamoDBTableName, hashKeyAttribute and rangeKeyAttribute.