ValidationException:提供的 AttributeValue 为空,必须恰好包含一种受支持的数据类型

ValidationException : Supplied AttributeValue is empty, must contain exactly one of the supported datatypes

我正在尝试在名为 Users 的 DynamoDB table 中插入一条新记录。我正在从 table 获取数据。但是每当我尝试插入新记录时,都会出现以下错误 -

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"}]

我的问题是导致此异常的原因是什么?我得到它的原因是什么?我确定我没有任何空变量(您可以在附加信息中看到)

问题信息:

这是我正在尝试做的事情的完整日志 -

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}]

我曾尝试将虚拟数据放入数据模型中,使其没有任何空变量。但是好像不行。

这是我插入记录的方式 -

-(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;
     }];
}

我的数据模型如下所示 -

@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";
}

从日志来看NSMutableArray catalog_ids仍然是空的:

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

DynamoDB Data Model 的文档中提到 DynamoDB 不支持多值数据类型的空集。尝试用非零值初始化数组。