I'm working on transferring my project from AFNetworking to Alamofire. Really like the project. POST requests work just fine, however, I'm receiving this error when attempting to make a GET request.
Here's some example code:
class func listCloudCredntials(onlyNew onlyNew: Bool = true, includePending: Bool = true) -> Request {
let parameters: [String: AnyObject] = includePending ? ["include_pending": "true"] : [:]
let urlString = "https://myapp-staging.herokuapp.com/api/1/credntials"
let token = SSKeychain.storedToken()
let headers: [String: String] = ["Authorization": "Bearer \(token)"]
return Alamofire.request(.GET, urlString, parameters: parameters, encoding: .JSON, headers: headers)
}
I receive this error: : -1005 The network connection was lost
However, if I change the request type to .POST
, the request "works". I receive a 401 code, but at least the request doesn't lose Network connection.
What am I doing wrong?