Alamofire Basic Authorization not working

Alamofire Basic Authorization not working

I am using the Alamofire to make a get call to REST API which requires authorization information with each API call. If I include the authorization header I get “Network connection was lost error (error 1005)” and a nil response. If I don’t include the authorization header I get the correct HTML response (status 401 - Unauthorized).

I have tried various different code suggested online but I still get “Network connection was lost error”. I have also tried resetting the XCode Simulator. Can anyone please help?

    func makeGetCal3() {
    if let url = URL(string: "https://breakapi.warnerleisurehotels.co.uk/breakapi/acts/getacts?hotels=th") {
        var urlRequest = URLRequest(url: url)
        urlRequest.httpMethod = HTTPMethod.get.rawValue
        
        var headers: HTTPHeaders
        if let existingHeaders = urlRequest.allHTTPHeaderFields {
            headers = existingHeaders
        } else {
            headers = HTTPHeaders()
        }
        headers["Authorization"] = "Basic V2FybmVyOldMSDFwbB=="
        headers["Accept"] = "application/json"
        headers["API-Request-Time"] = "2017.03.18T10:30:23"
        urlRequest.allHTTPHeaderFields = headers
        
        Alamofire.request(url, parameters: nil, encoding: JSONEncoding.default, headers: headers)
            .responseJSON { response in
                debugPrint(response)
        }
    }
}