我想发送一个对象到服务器(PUT请求)没有映射,因为我已经有了我需要从服务器的一切。即使服务器已成功创建对象,回调也会直接失败。RestKit 0.20忽略putObject:映射
下面是我在做什么的例子:
- (void) PUTsuccess:(void (^)(RKObjectRequestOperation *operation, RKMappingResult *mappingResult))success
failure:(void (^)(RKObjectRequestOperation *operation, NSError *error))failure
{
RKObjectManager *objectManager = [YSManager objectManager];
[objectManager putObject:self path:[kPutPath stringByAppendingString:self.id] parameters:kAPIDefaultParameters success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"operation.HTTPRequestOperation.request.HTTPBody: %@", [[NSString alloc] initWithData:operation.HTTPRequestOperation.request.HTTPBody encoding:NSUTF8StringEncoding]);
if (success) {
success(operation, mappingResult);
}
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Failure! Error: %@", error.localizedDescription);
if (failure) {
failure(operation, error);
}
}];
}
在201创建的服务器响应,我可以在服务器找回我的对象,这样一切都很好,不过,回调直接触发故障因为它试图映射我的对象,故障回调中的错误是:
Error: No response descriptors match the response loaded.
非常感谢,任何建议将不胜感激!
更新1 增补字典现在映射:
RKObjectMapping *idMapping = [RKObjectMapping requestMapping];
[idMapping addAttributeMappingsFromArray:@[]];
RKResponseDescriptor *responseDescriptorID = [RKResponseDescriptor responseDescriptorWithMapping:idMapping
pathPattern:[kRequestPath stringByAppendingString:@":code"]
keyPath:@"objects"
statusCodes:statusCodes];
尝试使用keyPath:nil并仔细检查pathPattern。 – Roger 2013-05-07 23:49:05