iosobjective-crestkit

RestKit The mapping operation was unable to find any nested object representations at the key paths searched


I want to post a request with User object to register but I am getting this error:

The mapping operation was unable to find any nested object representations at the key paths searched

Here is my code for posting the request:

User * user = [[User alloc]init];
user.UserName = _userNameTextField.text;
user.Password = _passwordTextField.text;
user.ConfirmPassword = _passwordTextField.text;
user.Email = _emailTextField.text;
//    {
//        "Email": "sample string 1",
//        "UserName": "sample string 2",
//        "Password": "sample string 3",
//        "ConfirmPassword": "sample string 4"
//    }
RKObjectManager * objectmanager = [RKObjectManager managerWithBaseURL:[NSURL URLWithString:@"url"]];
RKObjectMapping * userMapping = [RKObjectMapping requestMapping];
[userMapping addAttributeMappingsFromArray:@[@"Email",@"UserName",@"Password",@"ConfirmPassword"]];


RKRequestDescriptor * registrationDescriptor = [RKRequestDescriptor requestDescriptorWithMapping:userMapping objectClass:[User class] rootKeyPath:@"api/Account/Register/" method:RKRequestMethodPOST];
[objectmanager addRequestDescriptor:registrationDescriptor];

[objectmanager postObject:user path:@"api/Account/Register/" parameters:nil success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
    NSLog(@"Success");
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
    NSLog(@"Fail");
}];

Any help is extremely appreciated.

Solution

The solution was to delete the root key path.


Solution

    1. Try remove trailing slash in path (@"api/Account/Register" instead of @"api/Account/Register/")
    2. If nothing changed, turn on logging to trace level for object mapping RKLogConfigureByName("RestKit/ObjectMapping", RKLogLevelTrace); You will see additional information in console.