title: Error Domain=NSURLErrorDomain Code=-1017 "The operation couldn’t be
body: <p>I just started ios development and I'm trying to exchange data with my api. When I'm doing POST requests everything is going fine but when I'm trying to do a GET request I get the following error:  </p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-1017 "The operation couldn’t be
    completed. (NSURLErrorDomain error -1017.)" UserInfo=0x145a2c00
    {NSErrorFailingURLStringKey=<a href="http://myAPI.com/" rel="noreferrer">http://myAPI.com/</a>,
    _kCFStreamErrorCodeKey=-1, NSErrorFailingURLKey=<a href="http://myAPI.com" rel="noreferrer">http://myAPI.com</a>,
    _kCFStreamErrorDomainKey=4, NSUnderlyingError=0x145b21d0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error
    -1017.)"}</p>
  </blockquote>
  
  <p>Could someone explain what's going wrong and how I can fix it?</p>
  
  <p>My request:</p>
  
  <pre><code>-(void)hitApiWithURL:(NSString*)url HTTPMethod:(NSString*)HTTPMethod params:(NSDictionary*)params successBlock:(successTypeBlock)success  failureBlock:(errorTypeBlock)failure{
  
  
      NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration defaultSessionConfiguration];
      NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfig delegate:self delegateQueue:nil];
  
  
      [sessionConfig setHTTPAdditionalHeaders:@{@"Content-type": @"application/json"}];
      NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
      [request setHTTPMethod:HTTPMethod];
  
      // The body
      NSError *error = nil;
      NSData *jsonData = [NSJSONSerialization dataWithJSONObject:params options:0 error:&amp;error];
      [request setHTTPBody:jsonData];
  
  
      NSURLSessionDataTask *dataTaks = [session dataTaskWithRequest:request];
      [dataTaks resume];
  
      NSLog(@"dataTask started");
  
  }
  
  
  - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task
  didCompleteWithError:(NSError *)error {
      if (error) {
          //Gives my error
      }
      else {
          // do something:
      }
  }
  </code></pre>