我正在尝试为登录屏幕发布一个简单的帖子。我发布了电子邮件地址和密码。这给了我一个带有状态代码的 JSON。如果此代码为 200,则它还包含一个 person 对象。如果是其他东西,它包含一个错误对象。
我有这个代码用于发布。
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];
但是此代码导致以下错误。
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: route'
*** First throw call stack:
有人可以帮我吗?我是restkit的新手。
亲切的问候
最佳答案
您尝试使用自动路由发布对象,但是您的对象为零。因此,它将依赖路径参数来确定 POST 到哪里。这也是零。
您需要使用公共(public)基本 URL 创建对象管理器,例如。 http://******.com.be/nl/webservice/company-user
并为您的方法提供路径参数 /login/apikey/key**
关于objective-c - Restkit路由错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14196908/