title: Getting "The network connection was lost." error when calling API using Alamofire library in MAC OS App
body: <p>I have integrated <a href="https://github.com/Alamofire/Alamofire" rel="nofollow noreferrer">Alamofire</a> Library for API calling, and getting following error :</p>
  
  <blockquote>
    <p>Error Domain=NSURLErrorDomain Code=-1005 "The network connection was
    lost." UserInfo={_kCFStreamErrorCodeKey=57,
    NSUnderlyingError=0x600000c68990 {Error Domain=kCFErrorDomainCFNetwork
    Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=57,
    _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .&lt;1>,
    _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalDataTask .&lt;1>" ), NSLocalizedDescription=The network connection was lost.,
    NSErrorFailingURLStringKey=OUR_Server_URL,
    NSErrorFailingURLKey=OUR_Server_URL,
    _kCFStreamErrorDomainKey=1}</p>
  </blockquote>
  
  <p>I have added following property into .plist file too :</p>
  
  <pre><code>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt;
  &lt;dict&gt;
      &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;
      &lt;true/&gt;
  &lt;/dict&gt;
  </code></pre>
  
  <p>I am using Alamofire using following code :-</p>
  
  <pre><code>Alamofire code :
  
  func postFormDataWebService(methodType : HTTPMethod, contentType : String, url : String,
                                    parameters : NSMutableDictionary?,
                                    success: @escaping(_ response : NSDictionary, _ status : String) -&gt; Void,
                                    failure: @escaping(_ error : Error, _ status : Int) -&gt; Void){
  
      var headers : HTTPHeaders = [ "Content-Type": contentType, "accept": "application/json"]
  
      Alamofire.request(url, method: methodType, parameters:parameters as? [String : Any] , encoding: JSONEncoding.default, headers: headers)
          .responseJSON {
          (response:DataResponse) in
          var responseStatusCode: Int = 0
          switch response.result {
  
          case .success:
              responseStatusCode = (response.response?.statusCode)!
              let data = response.result.value as! NSDictionary
              print(data)
              success(data, data["status"] as? String ?? "")
  
              break
          case .failure(let error):
              responseStatusCode = response.response?.statusCode ?? 0
              print("statusCode :: ", response.response?.statusCode  ?? 0)
              print("Error :: ",error.localizedDescription)                
              failure(error,responseStatusCode)
          }
      }
  }
  
  API Calling function :
  
  ApiManager.shared.postFormDataWebService(methodType: :POST, contentType: "application/json", url: LoginUrl, parameters: parameters, 
  success: { (response, status) in
      print("response = \(response)")
      print("status = \(status)")
  }) { (error, status) in
      print("Login Error == \(error)\nStatus == \(status)")
  }
  </code></pre>
  
  <p>Any help would be appreciated.</p>