Restkit路线错误 [英] Restkit route error

查看:101
本文介绍了Restkit路线错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为登录屏幕做一个简单的帖子.我发布了一个电子邮件地址和密码.这给了我一个带有状态码的JSON.如果此代码为200,则它还包含一个person对象.如果是其他内容,则包含错误对象.

I am trying to do a simple post for a login screen. I post an email address and password. This gives me a JSON back with status-codes. If this code is 200 it also contains a person object. If it is something else it contains an error object.

我有要发布的代码.

RKObjectManager *manager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"http://******.com.be/nl/webservice/company-user/login/apikey/key**"]];


NSDictionary *dictionary = @{ @"email": _txtLogin.text, @"pwd": _txtPass.text};
NSMutableURLRequest *request = [manager requestWithObject:nil method:RKRequestMethodPOST path:nil parameters:dictionary];
RKObjectRequestOperation *operation = [manager objectRequestOperationWithRequest:request success:^(RKObjectRequestOperation *operation, RKMappingResult *result) {
    NSLog(@"Loading mapping result: %@", result);
}
failure:nil];
[operation start];

但是此代码导致以下错误.

But this code is causing the following error.

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: route'
*** First throw call stack:

有人可以帮助我吗?我是Restkit的新手.

Could anybody help me? I'm new to restkit.

亲切的问候

推荐答案

您正尝试使用自动路由发布对象,但是您的对象为nil.因此,它将依赖于path参数来计算POST到的位置.这也是零.

You're trying to post an object using automatic routing, however, your object is nil. Therefore, it will rely on the path parameter to work out where to POST to. This is also nil.

您需要使用通用基本URL创建对象管理器,例如. http://******.com.be/nl/webservice/company-user并为您的方法提供路径参数/login/apikey/key**

You need to create the object manager with a common base URL, eg. http://******.com.be/nl/webservice/company-user and supply your method with the path parameter /login/apikey/key**

这篇关于Restkit路线错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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