Search code examples
iosafnetworkingafnetworking-2afhttprequestoperationnsurlerrordomain

AFNetworking issue with UStream API request for channel's video list


This is probably something simple that I am just overlooking. I am trying to make an AFHTTPRequest from uStream's API using AFNetworking. I should be getting a JSON payload response back that lists all the videos on a uStream Channel. Here is my code:

NSURL *url = [NSURL URLWithString:@"https://api.ustream.tv/channels/12321320/videos.json"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"success");

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"failed");
}];

[operation start];

Everything works fine when testing in a browser but when trying to use AFNetworking I get a NSURLErrorDomain failure. Anyone have any suggestions?


Solution

  • My code was fine but there was an issue with my iphone simulator. Reset Content and Settings did the trick. Thanks to k6sandeep for the help.