Restkit route error

℡╲_俬逩灬. 提交于 2019-12-22 18:32:48

问题


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.

I have this code for posting.

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:

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

Kind regards


回答1:


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.

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**



来源:https://stackoverflow.com/questions/14196908/restkit-route-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!