Meera
Meera

Reputation: 1031

RestKit Response map issue - <RKMappingResult:, results={ "<null>" =

I am using rest kit 0.20.0. I have a request in JSON format which is like

{
  "CreateSession" : yes,
  "DistributionChannel" : "string1",
  "Login" : "string2",
  "Nickname" :"string3",
  "Password" :"string4",
  "PhysicalDevice" :
   {
     "DeviceId" : "string5",
     "DeviceTypeCode" : 123,
     "PhysicalDeviceTypeCode" : 1233,
    }
}

I did this

 NSDictionary * dictionary = @{
                            @"CreateSession":@"yes",
                            @"DistributionChannel":@"string1",
                            @"Login": @"string2",
                            @"Nickname":  @"string3",
                            @"Password":  @"string4",
                            @"PhysicalDevice":  @{ @"DeviceId":  @"string5",
                                                   @"DeviceTypeCode":  @"123",
                                                   @"PhysicalDeviceTypeCode": @"1233" }
                            };


    RKObjectMapping *registerDeviceRequestMapping = [RKObjectMapping requestMapping];
        [registerDeviceRequestMapping addAttributeMappingsFromDictionary:dictionary];

created descriptors for request and response separately. Added it to the RKObjectManager shared object,also have set base url and headers.

I called this to start request

RKHTTPRequestOperation *operation = [[RKObjectManager sharedManager] appropriateObjectRequestOperationWithObject:dictionary method:RKRequestMethodPOST path:@"RegisterDevice" parameters:nil];

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
         NSLog(@"response   %@",[responseObject description]);

    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
         NSLog(@"Failed with error: %@", [error localizedDescription]);
    }];

        [operation start];

I get a 200 status but could not map values from response. The mapping result that I got is

<RKMappingResult: 0x849bf60, results={
    "<null>" = "<Response: 0x849b390>";

Tried several links but seems like none provides a good solution. The actual response that i need to map is

{
    "PhysicalDevice": {
        "AddDate": "string1",
        "AuthenticationKey": "string2",
        "DeviceId": "string3",
        "DeviceTypeCode": 33,
        "DeviceTypeName": "string4",
        "Id": 10130,
        "ModDate": "2013-09-27T07:21:34.240Z",
        "PhysicalDeviceTypeCode": 1233,
        "SerialNumber": "string5",
        "Status": 1,
        "StatusName": "string6"
    },
    "RemainingDeviceAssociations": 4,
    "SessionId": "string7"
}

Note: values in request and response are dummy values, but their structure is as given

Upvotes: 1

Views: 687

Answers (1)

Wain
Wain

Reputation: 119041

<RKMappingResult: 0x849bf60, results={ "<null>" = "<Response: 0x849b390>";

This looks like a valid response. The response mapping provides you with a dictionary where the key is the key path and the response is your designated object. So, in this case the key is nil and your object is Response. And Response doesn't implement the description method so you just get the address.

You haven't shown your mappings or descriptors so I can't say more. You may be able to look at the contents of Response in the debugger...

Upvotes: 2

Related Questions