I'm getting following error while fetching videos by keywords from youtube from my iOS application:
Error Domain=JSONModelErrorDomain Code=2 "Bad network response. Probably the JSON URL is unreachable." UserInfo=0x79d86730 {NSLocalizedDescription=Bad network response. Probably the JSON URL is unreachable.
Here is my code:
NSString* searchCall = [NSString stringWithFormat:@"https://www.googleapis.com/youtube/v3/search?part=snippet&q=cats&type=video&videoCaption=closedCaption&key=AIzaSyDmq5TM_NJrpNuDoMcnnWjdg8lITTyzbDM"];
[JSONHTTPClient getJSONFromURLWithString: searchCall
completion:^(NSDictionary *json, JSONModelError *err) {
NSLog(@"%@", err);
}];
Please help me in resolving the issue.
There is some problem with the api key, update it and it will work:
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",