问题
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