Generate cURL output from Alamofire request?

I just did this and it works:

let someRequest = Alamofire.request(.POST, servicePath, parameters: requestParams, encoding: .JSON)
debugPrint(someRequest)

Here's an updated answer for Swift 5 and AlamoFire 5

let headers: HTTPHeaders = [
    "Accept": "application/json"
]

AF.request(myURL, method: .get, headers: headers).validate().responseJSON { response in
    switch response.result {
        case .success(let value):
            print(value)
        case .failure(let error):
            print("oops")
            print(error)
        }
}.cURLDescription { description in
    print(description)
}

try this

let task = AF.request(url)
task.responseData { response in
   print(task.debugDescription)
}

from here

Tags:

Curl

Alamofire