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
Example directly from Alamofire github page:
Alamofire.request(.GET, "http://httpbin.org/get", parameters: ["foo": "bar"])
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.response { (_, _, _, error) in
println(error)
}
In your case add what you want:
Alamofire.request(.GET, "http://httpbin.org/get", parameters: ["foo": "bar"])
.validate(statusCode: 200..<300)
.validate(contentType: ["application/json"])
.validate(Accept: ["application/json"])
.response { (_, _, _, error) in
println(error)
}