I'm trying to make a GET request with Alamofire in Swift. I need to set the following headers:
Content-Type: application/json
Accept: application/json
I could hack around it and do it directly specifying the headers for the request, but I want to do it with ParameterEncoding
, as is suggested in the library. So far I have this:
Alamofire.request(.GET, url, encoding: .JSON)
.validate()
.responseJSON { (req, res, json, error) in
if (error != nil) {
NSLog("Error: \(error)")
println(req)
println(res)
} else {
NSLog("Success: \(url)")
var json = JSON(json!)
}
}
Content-Type
is set, but not Accept
. How can I do this properly?