title: iOS Can't perform HTTP GET request -Error Domain=NSURLErrorDomain Code=-1012
body: <p>I am trying to perform a HTTP Get request, but I keep on getting Error Domain=NSURLErrorDomain Code=-1012  error. MY code is :</p>
  
  <pre><code>@try {
      NSString *url = [[NSString alloc] initWithFormat:@"%@%@", @"http://api.mintchat.com/agent/chats/", agentSecret];
  
      NSLog(@"******Agents Active List URL Str - %@", url);
      NSURL *nsUrl = [NSURL URLWithString:url];  
      NSLog(@"******Agents Active List URL - %@", nsUrl);
  
     // Make the request, returning a JSON response, just as a plain old string.
     //NSData *jsonDataString = [[NSString stringWithContentsOfURL:[NSURL URLWithString:url] encoding:NSUTF8StringEncoding error: nil] dataUsingEncoding:NSUTF8StringEncoding];
  
      NSError *error = nil;
  
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:nsUrl];
      [request setHTTPMethod:@"GET"];
      [request setValue:API_ID forHTTPHeaderField:@"X-API-ID"];
      [request setValue:API_SECRET forHTTPHeaderField:@"X­-API-­SECRET"];
  
      NSHTTPURLResponse *response = nil;
      NSData *urlData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;error];
  
      NSLog(@"Response Code %d", [response statusCode]);
      if ([response statusCode] &gt;= 200 &amp;&amp; [response statusCode] &lt; 300) {
          NSString *responseData = [ [NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
         NSLog(@"Response  ==&gt; %@", responseData);        
      } else {
         if (error)
            NSLog(@"ERror : %@", error);
      }
  }@catch(NSException *e) {
          NSLog(@"Exception - %@", e);
     }
  </code></pre>
  
  <p>I am to get response in JSon, but as things are not working so we are trying with some normal response. I confirmed the Headers to be added to the request. I need to add the both values to the headers. The url is also proper.</p>
  
  <p>The results/logs I get is :
  Response Code 0</p>
  
  <blockquote>
    <p>Error : Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. 
        (NSURLErrorDomain error -1012.)" UserInfo=0x8abf470 {
        NSErrorFailingURLKey=.......NSErrorFailingURLStringKey=......NSUnderlyingError=0x8dafed0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1012.)"
        }</p>
  </blockquote>
  
  <p>I also searched a lot on net reg this error, bit couldn't get any substantial help. I also confirmed regarding access to the web server api. With other url also I get the same results. From 3 urls, I could achieve results of 1st url using POST, but those other 2 urls - just could't get thru it.</p>
  
  <p>Can anyone please help me with this problem. Where am going wrong ? Why can't access the api's. 
  Any help is highly appreciated.
  Thanks</p>