2015-04-20 6 views
2

J'essaie d'insérer un nouvel enregistrement dans une table DynamoDB nommée Users. Je reçois des données de la table. Mais chaque fois que je tente d'insérer un nouvel enregistrement, je reçois l'erreur suivante -ValidationException: fourni AttributeValue est vide, doit contenir exactement l'un des types de données pris en charge

AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:86 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: [{"__type":"com.amazon.coral.validate#ValidationException","message":"Supplied AttributeValue is empty, must contain exactly one of the supported datatypes"}] 

Ma question est ce qui cause cette exception et quelle serait la raison pour laquelle j'obtenir? Je suis sûr que je n'ai pas une variable vide (Vous pouvez voir dans l'info ci-jointe)

Informations sur la question:

Voici le journal complet de ce que je suis en train de faire -

AWSiOSSDKv2 [Verbose] AWSURLRequestSerialization.m line:111 | -[AWSJSONRequestSerializer serializeRequest:headers:parameters:] | Request body: [{"Key":{"phone_no":{"S":"Empty"}},"TableName":"Users","AttributeUpdates":{"signed_in_counts":{"Action":"DELETE"},"account_owner":{"Value":{"S":"Empty"},"Action":"PUT"},"email_id":{"Value":{"S":"Empty"},"Action":"PUT"},"catalog_ids":{"Value":{},"Action":"PUT"},"account_creation_date":{"Value":{"S":"Empty"},"Action":"PUT"},"title":{"Value":{"S":"Empty"},"Action":"PUT"},"date_of_birth":{"Value":{"S":"Empty"},"Action":"PUT"},"defaultOnlineStatus":{"Action":"DELETE"},"chat_enabled":{"Value":{"S":"YES"},"Action":"PUT"},"username":{"Value":{"S":"Empty"},"Action":"PUT"},"address_line1":{"Value":{"S":"Empty"},"Action":"PUT"},"last_name":{"Value":{"S":"Empty"},"Action":"PUT"},"last_date_of_sign_out":{"Value":{"S":"Empty"},"Action":"PUT"},"total_referrals":{"Action":"DELETE"},"last_date_signed_in":{"Value":{"S":"Empty"},"Action":"PUT"},"first_name":{"Value":{"S":"Empty"},"Action":"PUT"},"activated":{"Value":{"S":"YES"},"Action":"PUT"}}}] 
2015-04-20 15:44:53.434 Barnc[534:65423] AWSiOSSDKv2 [Debug] AWSSignature.m line:305 | -[AWSSignatureV4Signer signRequestV4:] | AWS4 Canonical Request: [POST 
/

accept-encoding: 
content-type:application/x-amz-json-1.0 
host:dynamodb.us-east-1.amazonaws.com 
user-agent:aws-sdk-iOS/2.1.0 iPhone-OS/8.3 en_IN 
x-amz-date:20150420T101453Z 
x-amz-security-token:XXX 
x-amz-target:DynamoDB_20120810.UpdateItem 

accept-encoding;content-type;host;user-agent;x-amz-date;x-amz-security-token;x-amz-target 
93a6af5de49c12a33621c58cbc3ea7c9bbd8cd59660531bef10ea81c36acb06f] 
2015-04-20 15:44:53.436 Barnc[534:65423] AWSiOSSDKv2 [Debug] AWSSignature.m line:306 | -[AWSSignatureV4Signer signRequestV4:] | payload {"Key":{"phone_no":{"S":"Empty"}},"TableName":"Users","AttributeUpdates":{"signed_in_counts":{"Action":"DELETE"},"account_owner":{"Value":{"S":"Empty"},"Action":"PUT"},"email_id":{"Value":{"S":"Empty"},"Action":"PUT"},"catalog_ids":{"Value":{},"Action":"PUT"},"account_creation_date":{"Value":{"S":"Empty"},"Action":"PUT"},"title":{"Value":{"S":"Empty"},"Action":"PUT"},"date_of_birth":{"Value":{"S":"Empty"},"Action":"PUT"},"defaultOnlineStatus":{"Action":"DELETE"},"chat_enabled":{"Value":{"S":"YES"},"Action":"PUT"},"username":{"Value":{"S":"Empty"},"Action":"PUT"},"address_line1":{"Value":{"S":"Empty"},"Action":"PUT"},"last_name":{"Value":{"S":"Empty"},"Action":"PUT"},"last_date_of_sign_out":{"Value":{"S":"Empty"},"Action":"PUT"},"total_referrals":{"Action":"DELETE"},"last_date_signed_in":{"Value":{"S":"Empty"},"Action":"PUT"},"first_name":{"Value":{"S":"Empty"},"Action":"PUT"},"activated":{"Value":{"S":"YES"},"Action":"PUT"}}} 
2015-04-20 15:44:53.439 Barnc[534:65423] AWSiOSSDKv2 [Debug] AWSSignature.m line:322 | -[AWSSignatureV4Signer signRequestV4:] | AWS4 String to Sign: [AWS4-HMAC-SHA256 
20150420T101453Z 
20150420/us-east-1/dynamodb/aws4_request 
3d4769e2a1f73aee21f7ef26ae389183852118fbf078261e1a293262f0ac97d3] 
2015-04-20 15:44:54.748 Barnc[534:66289] AWSiOSSDKv2 [Debug] AWSURLResponseSerialization.m line:81 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response header: [{ 
    "Content-Length" = 156; 
    "Content-Type" = "application/x-amz-json-1.0"; 
    Date = "Mon, 20 Apr 2015 10:14:53 GMT"; 
    "x-amz-crc32" = 1541720790; 
    "x-amzn-RequestId" = XXX; 
}] 
2015-04-20 15:44:54.748 Barnc[534:66289] AWSiOSSDKv2 [Verbose] AWSURLResponseSerialization.m line:86 | -[AWSJSONResponseSerializer responseObjectForResponse:originalRequest:currentRequest:data:error:] | Response body: 

[{"__type":"com.amazon.coral.validate#ValidationException","message":"Supplied AttributeValue is empty, must contain exactly one of the supported datatypes"}] 
The request failed. Error: [Error Domain=com.amazonaws.AWSDynamoDBErrorDomain Code=0 "The operation couldn’t be completed. (com.amazonaws.AWSDynamoDBErrorDomain error 0.)" UserInfo=0x1760c310 {message=Supplied AttributeValue is empty, must contain exactly one of the supported datatypes, __type=com.amazon.coral.validate#ValidationException}] 

J'ai essayé de mettre des données factices dans le modèle de données pour n'avoir aucune variable vide. Mais cela ne semble pas fonctionner.

Voilà comment j'insérez le disque -

-(void)saveUser:(BarncUser*)user{ 
    [user autoValidate]; 
    [[dynamoDBObjectMapper save:user.amazonUser] 
    continueWithBlock:^id(BFTask *task) { 
     if (task.error) { 
      NSLog(@"The request failed. Error: [%@]", task.error); 
     } 
     if (task.exception) { 
      NSLog(@"The request failed. Exception: [%@]", task.exception); 
     } 
     if (task.result) { 
      //Do something with the result. 
     } 
     return nil; 
    }]; 
} 

Mes données modèle ressemble à ceci -

@interface AmazonUser : AWSDynamoDBObjectModel <AWSDynamoDBModeling> 

@property (nonatomic, strong) NSString *phone_no; 
@property (nonatomic, strong) NSString *activated; 
@property (nonatomic, strong) NSMutableArray *catalog_ids; 
@property (nonatomic, strong) NSNumber *defaultOnlineStatus; 
@property (nonatomic, strong) NSNumber *signed_in_counts; 
@property (nonatomic, strong) NSNumber *total_referrals; 
@property (nonatomic, strong) NSString *account_creation_date; 
@property (nonatomic, strong) NSString *email_id; 
@property (nonatomic, strong) NSString *account_owner; 
@property (nonatomic, strong) NSString *username; 
@property (nonatomic, strong) NSString *first_name; 
@property (nonatomic, strong) NSString *chat_enabled; 
@property (nonatomic, strong) NSString *last_name; 
@property (nonatomic, strong) NSString *title; 
@property (nonatomic, strong) NSString *last_date_of_sign_out; 
@property (nonatomic, strong) NSString *date_of_birth; 
@property (nonatomic, strong) NSString *last_date_signed_in; 
@property (nonatomic, strong) NSString *address_line1; 

- (void)createDummy; 

@end 

@implementation AmazonUser 

+ (NSString *)dynamoDBTableName { 
    return @"Users"; 
} 

+ (NSString *)hashKeyAttribute { 
    return @"phone_no"; 
} 

- (void)createDummy{ 

    self.phone_no = @"Empty"; 
    self.activated = @"YES"; 
    self.catalog_ids = [[NSMutableArray alloc]init]; 
    self.defaultOnlineStatus = 0; 
    self.signed_in_counts = 0; 
    self.total_referrals = 0; 
    self.account_creation_date = @"Empty"; 
    self.email_id = @"Empty"; 
    self.account_owner = @"Empty"; 
    self.username = @"Empty"; 
    self.first_name = @"Empty"; 
    self.chat_enabled = @"YES"; 
    self.last_name = @"Empty"; 
    self.title = @"Empty"; 
    self.last_date_of_sign_out = @"Empty"; 
    self.date_of_birth = @"Empty"; 
    self.last_date_signed_in = @"Empty"; 
    self.address_line1 = @"Empty"; 
} 

Répondre

4

Le NSMutableArray catalog_ids est encore vide juger du journal:

catalog_ids":{"Value":{},"Action":"PUT"} 

Dans la documentation sur le DynamoDB Data Model, il est mentionné que DynamoDB ne s ajouter des ensembles vides pour les types de données à plusieurs valeurs. Essayez d'initialiser le tableau avec des valeurs non nulles.

+0

Et j'ai passé 3 jours à résoudre tout cela par moi-même. Merci pour l'aide. – noob