I am trying to fetch movie data from the OMDb API
The response OMDb provides has a wrong content-type but I was able to circumvent this. However, I still receive errors from AFNetworking:
Error while fetching IMDBSingleMovieData: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x10a7451d0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
Code:
// add url request parameters
NSDictionary* parameters = @{ @"i" : [NSString stringWithFormat:@"tt%d", identifier] };
// run the request operation
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager POST:@"http://www.omdbapi.com" parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.singleIMDBMovieData = [NSDictionary dictionaryWithDictionary:responseObject];
[self.delegate updateIMDBMovieDetails];
NSLog(@"Object returned %@", self.singleIMDBMovieData);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error while fetching IMDBSingleMovieData: %@", error);
}];
What can I do to fix this? Sample response from API: http://www.omdbapi.com/?i=tt0993846