RestKit - Response descriptor not added

36 Views Asked by At

I use RestKit version 0.26 and try to map a response to core data

This is the code I use for the code I use to built the request and Descriptor:

    -(void)getProductListProductWithPageNumber: (int) pageNumber managedObjectStore: (RKManagedObjectStore *)managedObjectStore {

    // initialize AFNetworking HTTPClient
    NSURL *baseURL = [NSURL URLWithString:@"https://server.com"];
    AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:baseURL];

    RKObjectManager *objectManager = [[RKObjectManager alloc] initWithHTTPClient:client];


    objectManager.managedObjectStore = managedObjectStore;



    RKResponseDescriptor *productListrResponseDescriptor =
    [RKResponseDescriptor responseDescriptorWithMapping:[[CategoricalSystemDownloadManager sharedDownloadManager] getCDProductListProductMapping:managedObjectStore]
                                                 method:RKRequestMethodGET
                                            pathPattern:@"/PLController/plProducts/:"
                                                keyPath:nil
                                            statusCodes:[NSIndexSet indexSetWithIndex:200]];

    [objectManager addResponseDescriptor:productListrResponseDescriptor];

    [objectManager getObjectsAtPath:[NSString stringWithFormat:@"/PLController/plProducts/currentResponseBody-%d", pageNumber]
                         parameters:nil
                            success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {

                            }
                            failure:^(RKObjectRequestOperation *operation, NSError *error) {
                            }];
 }

The mapped JSON does is an array -> key path nil, right? It looks like this: [ { "productId": 240, "brandId": 69 } ]

This is the error

 which failed to match all (0) response descriptors
1

There are 1 best solutions below

0
HasenBaumeister On

I messed up the pathPattern. It should be /PLController/plProducts/:currentResponseBody