I have a link which contains the a json file. I mean if I launch that link in chrome a file is downloaded on my computer which is of .json extension.
say the link is www.foffa.com/sampleList.json
I am new to AFNetworking and not sure how to parse this json, with or without having to write this file down to the disk.
My code looks like below and I am pretty sure that I have to use streams and all for this but I am not sure how. As of now I get an error "Request failed: unacceptable content-type: text/plain"
I guess it expects the content type to be "Content-Type" = "application/octet-stream";
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFHTTPResponseSerializer serializer];
operation.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/octet-stream"];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Data retrived");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error Retrieving Weather"
message:[error localizedDescription]
delegate:nil
cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alertView show];
}];
text/plain. Either you need to get it changed from your server side to the one you are accepting or you need to addtext/plainas acceptable content types.