Restkit请求不发送参数 [英] Restkit request not sending parameters

查看:150
本文介绍了Restkit请求不发送参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的实现不是发送参数。这是RequestDescriptor:

My implementation is not sending parameters. Here is the RequestDescriptor:

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 参数。关于为什么的任何想法?

In the server, I only receive one empty current_user parameter. Any ideas on why?

PD。服务器期望

推荐答案

确保你有set:

manager.requestSerializationMIMEType = RKMIMETypeJSON;

默认为 RKMIMETypeFormURLEncoded

根据您的评论和讨论,由于用户的类错误,因此未使用映射。这是因为它是一个简单的 NSManagedObject 而不是 RKUser 实例。这意味着RestKit找不到合适的映射。原因是您的核心数据模型中的用户实体未设置自定义类。

Based on your comments and discussion, the mapping isn't being used because the class of the user is wrong. This is because it is a plain NSManagedObject rather than an RKUser instance. This means RestKit can't find the appropriate mapping. The cause for this is the custom class not being set on the User entity in your Core Data model.

这篇关于Restkit请求不发送参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆