RestKit Response in text/javascript in iOS



I am implementing Rotten Tomate API with Restkit, However it's always returning error



NSLocalizedDescription=Expected content type {(
"application/x-www-form-urlencoded",
"application/json",
"application/xml"
)}, got text/javascript}


Below is my code. Let me know what i am doing wrong



RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[Movie class]];
[mapping addAttributeMappingsFromArray:@[@"movieID", @"title", @"year"]];

NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:mapping method:RKRequestMethodAny pathPattern:@"" keyPath:@"" statusCodes:statusCodes];

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://ift.tt/1x3cVng"]];

[RKMIMETypeSerialization registerClass:[RKMIMETypeSerialization class] forMIMEType:@"application/xml"];
[[RKObjectManager sharedManager] setAcceptHeaderWithMIMEType:RKMIMETypeJSON];

RKObjectRequestOperation *operation = [[RKObjectRequestOperation alloc] initWithRequest:request responseDescriptors:@[responseDescriptor]];
[operation setCompletionBlockWithSuccess:^(RKObjectRequestOperation *operation, RKMappingResult *result) {

Movie *article = [result firstObject];
NSLog(@"Mapped the article: %@", article);
} failure:^(RKObjectRequestOperation *operation, NSError *error) {
NSLog(@"Failed with error: %@", [error localizedDescription]);
}];
[operation start];

No comments:

Post a Comment