Reputation: 11390
I have been seeing quite a few posts of this nature where a trailing '/' (or lack of) causes the pattern matching to fail.
My problem, however, is that there is no pattern to match against. My error looks like this:
"No response descriptors match the response loaded." UserInfo=0xcb8a660 {NSErrorFailingURLStringKey=http://domain.herokuapp.com/auth/identity/callback, NSLocalizedFailureReason=A 200 response was loaded from the URL 'http://domain.herokuapp.com/auth/identity/callback', which failed to match all (3) response descriptors: http://domain.herokuapp.com pathPattern=(null) statusCodes=200-299> failed to match: response path '/auth/identity/callback' did not match the path pattern '(null)'.
"did not match the path pattern '(null)'" is what I assume is the problem.
Setting up the objectmanager and HttpClient:
+ (void) fireUpRestkit
{
RKLogConfigureByName("RestKit/Network", RKLogLevelTrace);
//base URL @"http://domain.herokuapp.com"
NSURL *baseURL = [[SCURLManager sharedInstance] baseURL];
AFHTTPClient * client = [AFHTTPClient clientWithBaseURL:baseURL];
[client setDefaultHeader:@"Accept" value:RKMIMETypeJSON];
RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];
NSAssert(objectManager, @"objectManager did not instantiate correctly");
}
My request looks like this:
[[RKObjectManager sharedManager] postObject:user
path:/auth/identity/callback"
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
My descriptors are setup like this:
RKObjectManager *objectManager = [RKObjectManager sharedManager];
RKObjectMapping *userMapping = [RKObjectMapping mappingForClass:[SCUserEntity class]];
[userMapping addAttributeMappingsFromDictionary:[SCUserEntity keyMapping]];
RKRequestDescriptor * requestDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:userMapping.inverseMapping
objectClass:[SCUserEntity class]
rootKeyPath:nil
method:RKRequestMethodPOST];
RKResponseDescriptor * responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:userMapping
method:RKRequestMethodGET
pathPattern:nil
keyPath:nil statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
[objectManager addResponseDescriptor:responseDescriptor];
[objectManager addRequestDescriptor:requestDescriptor];
I can't find the reason for the pattern I give when doing the postRequest does not seem to
be there when the request returns.
I have stepped through the buildResponseMappingsDictionary
and subsequent matches~ methods. When the request is made they all return the correct descriptors, but when the request needs mapping it doesn't work.
I get a 200 OK from the server, I see both the request and response bodies and they seem correct.
Hope someone can help me spot the probably obvious missing part:)
Upvotes: 1
Views: 1685
Reputation: 119031
It has nothing to do with the path pattern. It's the method.
You are using:
[[RKObjectManager sharedManager] postObject:user ...
but you have a response descriptor:
method:RKRequestMethodGET
i.e. one for POST and one for GET
Upvotes: 5