【发布时间】:2013-12-11 03:28:20
【问题描述】:
我的实现没有发送参数。这是请求描述符:
RKObjectMapping *userMapping = [RKObjectMapping requestMapping];
[userMapping addAttributeMappingsFromArray:@[@"nombres", @"telefono", @"direccion", @"email", @"identificacion", @"tipo_id", @"recibir_sms_ordenes", @"recibir_correos_ordenes"]];
RKRequestDescriptor *descriptor = [RKRequestDescriptor requestDescriptorWithMapping:userMapping objectClass:[RKUser class] rootKeyPath:@"me" method:RKRequestMethodAny];
[[RKObjectManager sharedManager] addRequestDescriptor:descriptor];
这是发帖请求:
RKUser *user = [self currentUser].user; // [self currentUser].user returns the current RKUser
RKObjectManager *manager = [RKObjectManager sharedManager];
[manager postObject:user path:@"/api/me.json" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
NSLog(@"%@ %@", operation, mappingResult);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"%@ %@", error, operation);
}];
在服务器中,我只收到一个空的current_user 参数。关于为什么的任何想法?
PD。服务器期望在me 键下的 JSON 有效负载
【问题讨论】:
-
“参数”是什么意思?服务器期望收到什么?您是否将请求序列化类型设置为 JSON?
-
@Wain 我该怎么做?服务器期望 JSON 中的对象也许这就是我所缺少的
标签: ios iphone objective-c restkit restkit-0.20