I'm trying to read a simple json string response from a web service :
Suppose I have this mapping :
RKObjectMapping* loginRequestMapping = [RKObjectMapping requestMapping];
[loginRequestMapping addAttributeMappingsFromDictionary:@{
@"userName" : @"UserName",
@"password" : @"Password"
}];
RKRequestDescriptor* loginReq = [RKRequestDescriptor requestDescriptorWithMapping:loginRequestMapping objectClass:[LoginRequest class] rootKeyPath:nil method:RKRequestMethodPOST];
[objectManager addRequestDescriptor:loginReq];
I tried this request :
LoginRequest* loginReq = [LoginRequest new];
loginReq.userName = @"username";
loginReq.password = @"1234567890";
__block NSString* token;
[objectManager postObject:loginReq
path:@"/sendboxapi/api/login"
parameters:nil
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
token = [mappingResult firstObject];
NSLog(@"RESULT : %@", token);
}
failure:^(RKObjectRequestOperation *operation, NSError *error) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
NSLog(@"Hit error: %@", error);
}];
The raw response have this format : "47c4e389-be2b-466b-b015-c8d5682c4f0a"
I get this error : Hit error: Error Domain=org.restkit.RestKit.ErrorDomain Code=-1017 "Loaded an unprocessable response (200) with content type 'application/json'"
What is the Correct RKObjectMapping to set to be able to read this string from the webservice ?
Thank you