Ios 添加到RestKit请求的不需要的会话参数

Ios 添加到RestKit请求的不需要的会话参数,ios,ruby-on-rails,devise,restkit,Ios,Ruby On Rails,Devise,Restkit,我正在尝试使用RestKit 0.20.0登录到运行Desive的RoR后端。我正在尝试使用以下参数实现请求: Parameters: {"password"=>"[FILTERED]", "email"=>"email@mail.com"} 但在服务器上实际接收到的内容如下: Parameters: {"password"=>"[FILTERED]", "email"=>"email@mail.com", "session"=>{"password"=>"

我正在尝试使用RestKit 0.20.0登录到运行Desive的RoR后端。我正在尝试使用以下参数实现请求:

Parameters: {"password"=>"[FILTERED]", "email"=>"email@mail.com"}
但在服务器上实际接收到的内容如下:

Parameters: {"password"=>"[FILTERED]", "email"=>"email@mail.com", "session"=>{"password"=>"[FILTERED]", "email"=>"email@mail.com"}}
我不知道这个会话参数来自哪里。当我做一个GET时,它不会被添加,只有在做POST时才会被添加。登录成功,但响应完全错误。通过使用正确的参数列表,可以给出正确的响应。下面是发送请求的代码。关于这个会话参数的来源有什么想法吗

- (void)loginWithblock:(void (^)(bool))block
{
NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:_username, @"email", _password, @"password", nil];
NSString *url = [[MBMSettingsHelper sharedSettingsHelper] authenticationURL];

[[RKObjectManager sharedManager] postObject:nil path:url parameters:params
                                    success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
                                        block(YES);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
    block(NO);
}];
}
在我的appdelegate中,我有以下映射器:

// Mappers for authentication
RKObjectMapping *requestMappingForAuthenticate = [RKObjectMapping requestMapping];
[requestMappingForAuthenticate addAttributeMappingsFromDictionary:@{
 @"username" : @"email",
 @"password": @"password"
 }];
RKRequestDescriptor *requestDescriptorForAuthenticate = [RKRequestDescriptor requestDescriptorWithMapping:requestMappingForAuthenticate objectClass:[MBMUserLoginRequest class] rootKeyPath:nil];

RKObjectMapping *responseMappingForAuthenticate = [RKObjectMapping requestMapping];
[responseMappingForAuthenticate addAttributeMappingsFromDictionary:@{
 @"success": @"success",
 @"auth_token": @"token",
 @"email": @"username",
 @"id": @"userId"}];
RKResponseDescriptor *responseDescriptorForAuthenticate = [RKResponseDescriptor responseDescriptorWithMapping:responseMappingForAuthenticate pathPattern:nil keyPath:nil statusCodes:nil];

[objectManager addResponseDescriptor:responseDescriptorForAuthenticate];
[objectManager addRequestDescriptor:requestDescriptorForAuthenticate];
编辑:

RestKit日志发布在下面。看起来在登录之后,映射器开始用一个完全不同的模型(在本例中是船)映射登录响应

2013-05-24 01:33:59.649 xxx[8153:637f]D restkit.对象映射:RKMapperOperation.m:241请求映射源对象{
“认证令牌”=xxx;
电子邮件=“xxx”;
id=2;
成功=1;
}带映射
2013-05-24 01:33:59.652 xxx[8153:637f]D restkit.对象映射:RKMappingOperation.m:862正在启动映射操作。。。
2013-05-24 01:33:59.653 xxx[8153:637f]T restkit.对象映射:RKMappingOperation.m:863执行映射操作:针对“\u NSDictionaryM”对象。从对象映射值{
“认证令牌”=xxx;
电子邮件=“xxx”;
id=2;
成功=1;
}反对{
}具有对象映射(空)
2013-05-24 01:33:59.655 xxx[8153:637f]T restkit.对象映射:RKMappingOperation.m:458将属性值keyPath“id”映射到“boatId”
2013-05-24 01:33:59.656 xxx[8153:637f]T restkit.对象映射:RKMappingOperation.m:480将属性值从键路径“id”映射到“boatId”。价值:2
2013-05-24 01:33:59.657 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath'year'
2013-05-24 01:33:59.658 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“factory”
2013-05-24 01:33:59.659 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“gearnumber”
2013-05-24 01:33:59.659 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“Harbor”
2013-05-24 01:33:59.660 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“EngineMufactory”
2013-05-24 01:33:59.661 xxx[8153:637f]T restkit.对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath'updated_at'
2013-05-24 01:33:59.662 xxx[8153:637f]T restkit.对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath'created_at'
2013-05-24 01:33:59.663 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“docknumber”
2013-05-24 01:33:59.664 xxx[8153:637f]T restkit.对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“insurancecompany”
2013-05-24 01:33:59.664 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“model”
2013-05-24 01:33:59.665 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath'name'
2013-05-24 01:33:59.666 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“enginemodel”
2013-05-24 01:33:59.667 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“enginenumber”
2013-05-24 01:33:59.667 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath'engineyear'
2013-05-24 01:33:59.668 xxx[8153:637f]T restkit对象映射:RKMappingOperation.m:525未找到可映射属性值keyPath“geartype”
2013-05-24 01:33:59.669 xxx[8153:637f]D restkit对象映射:RKMappingOperation.m:926成功完成映射操作。。。
2013-05-24 01:33:59.670 xxx[8153:637f]D restkit.对象映射:RKMapperOperation.m:414已完成对象映射。结果:{
"" =     {
boatId=2;
};
编辑2:
当我删除我的其他RKResponseDescriptor时,一切正常。所以问题是,在映射发生时,RKResponseDescriptor选择了错误的RKResponseDescriptor…

请发布RestKit日志以查看实际情况。RKLogConfigureByName(“RestKit/ObjectMapping”,RKLogLevelTrace);RKLogConfigureByName(“RestKit/Network”,RKLogLevelTrace);我不确定-问题是否仍然存在?也许你需要调整你的参数,因为你已经全部设置为nil:
pathPattern:nil keyPath:nil statusCodes:nil
?问题仍然存在。我不认为我可以使用pathPattern或keyPath,因为我的JSON响应只是一个简单的数组。我尝试发送一个对象而不是参数rs,但运气不好。我想做的是发送参数而不发送对象,然后根据我得到的任何映射结果创建一个对象。我确实得到了一个结果,但它嵌入到一个nil数组中:
results={'={success=1;token=hevlvvvqncufktpdbs2;userId=2;username=“xx”};}
pathPattern是接收响应的URL。是否定义了更多响应映射程序?请尝试
RKLogConfigureByName(“RestKit/*”,RKLogLevelTrace);
并将完整日志发布到pastebin或其他地方。
2013-05-24 01:33:59.649 xxx[8153:637f] D restkit.object_mapping:RKMapperOperation.m:241 Asked to map source object {
"auth_token" = xxx;
email = "xxx";
id = 2;
success = 1;
} with mapping <RKObjectMapping:0x1d5213a0 objectClass=NSMutableDictionary propertyMappings=(
"<RKAttributeMapping: 0x1d51a120 id => boatId>",
"<RKAttributeMapping: 0x1d54ec90 year => year>",
"<RKAttributeMapping: 0x1d54ecb0 factory => manufacturer>",
"<RKAttributeMapping: 0x1d528b40 gearnumber => sterndriveNumber>",
"<RKAttributeMapping: 0x1d528b80 harbour => homeHarbour>",
"<RKAttributeMapping: 0x1d54ea80 enginemanufactory => engineManufacturer>",
"<RKAttributeMapping: 0x1d54e9f0 updated_at => updatedAt>",
"<RKAttributeMapping: 0x1d54ed00 created_at => createdAt>",
"<RKAttributeMapping: 0x1d54ee70 docknumber => dockNumber>",
"<RKAttributeMapping: 0x1d54ed30 insurancecompany => insuranceCompany>",
"<RKAttributeMapping: 0x1d54edd0 model => model>",
"<RKAttributeMapping: 0x1d54ede0 name => name>",
"<RKAttributeMapping: 0x1d54f0e0 enginemodel => engineModel>",
"<RKAttributeMapping: 0x1d54f170 enginenumber => engineNumber>",
"<RKAttributeMapping: 0x1d54ed40 engineyear => engineYear>",
"<RKAttributeMapping: 0x1d54ed50 geartype => sterndriveType>"
)>
2013-05-24 01:33:59.652 xxx[8153:637f] D restkit.object_mapping:RKMappingOperation.m:862 Starting mapping operation...
2013-05-24 01:33:59.653 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:863 Performing mapping operation: <RKMappingOperation 0x1e325070> for '__NSDictionaryM' object. Mapping values from object {
"auth_token" = xxx;
email = "xxx";
id = 2;
success = 1;
} to object {
} with object mapping (null)
2013-05-24 01:33:59.655 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:458 Mapping attribute value keyPath 'id' to 'boatId'
2013-05-24 01:33:59.656 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:480 Mapped attribute value from keyPath 'id' to 'boatId'. Value: 2
2013-05-24 01:33:59.657 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'year'
2013-05-24 01:33:59.658 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'factory'
2013-05-24 01:33:59.659 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'gearnumber'
2013-05-24 01:33:59.659 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'harbour'
2013-05-24 01:33:59.660 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'enginemanufactory'
2013-05-24 01:33:59.661 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'updated_at'
2013-05-24 01:33:59.662 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'created_at'
2013-05-24 01:33:59.663 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'docknumber'
2013-05-24 01:33:59.664 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'insurancecompany'
2013-05-24 01:33:59.664 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'model'
2013-05-24 01:33:59.665 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'name'
2013-05-24 01:33:59.666 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'enginemodel'
2013-05-24 01:33:59.667 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'enginenumber'
2013-05-24 01:33:59.667 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'engineyear'
2013-05-24 01:33:59.668 xxx[8153:637f] T restkit.object_mapping:RKMappingOperation.m:525 Did not find mappable attribute value keyPath 'geartype'
2013-05-24 01:33:59.669 xxx[8153:637f] D restkit.object_mapping:RKMappingOperation.m:926 Finished mapping operation successfully...
2013-05-24 01:33:59.670 xxx[8153:637f] D restkit.object_mapping:RKMapperOperation.m:414 Finished performing object mapping. Results: {
"<null>" =     {
    boatId = 2;
};