Im working on an iOS app and am trying to use AFNetworking. Im trying to go to an http site and my request fails stating that it failed as an https request
NSString *urlString = [NSString stringWithFormat:@"http://api.openweathermap.org/data/2.5/weather?lat=%f&lon=%f&APPID=%@",lat, lon, [plistData objectForKey:@"weather"]];
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFJSONResponseSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
and the error response
Printing description of error:
Error Domain=NSURLErrorDomain Code=-1004
"Could not connect to the server."
UserInfo=0x7fa104a253d0 {
NSUnderlyingError=0x7fa104820950 "Could not connect to the server.",
NSErrorFailingURLStringKey=https://api.openweathermap.org/data/2.5/weather?lat=[removed]&lon=[removed]&APPID=[removed],
NSErrorFailingURLKey=https://api.openweathermap.org/data/2.5/weather?lat=[removed]&lon=[removed]&APPID=[removed], _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61,
NSLocalizedDescription=Could not connect to the server.}
on testing the site its the https part thats failing the site. As I'm not putting it in as https and explicitly putting in http I don't know whats wrong.
I'm using AFNetworking 2.5.1
To be clear, I am not trying to connect via https! I don't know why its assumed I am. Please read the whole question before posting an answer or suggesting duplication.
httpsso your network library fails to connect. You can't just say "I don't want to connect via https" as it is not up to you. - Ozgur Vatanseveroperation? - Ozgur VatansevercompletionHandler(weather); } failure:^(AFHTTPRequestOperation *operation, NSError *error) { Weather *weather; completionHandler(weather); }]; [operation start]; }This is after the code above surrounding my success code - DasScooter