Alamofire 4.0 - 设置请求内容类型

时间:2017-04-11 15:01:01

标签: ios swift alamofire

我正在使用Alamofire 4.4.0。 我需要在url字符串中发送带有params的POST请求(如在GET请求中),并且内容类型为“application / x-www-form-urlencoded”。

我的代码如下:

Alamofire.request(url, method: .post, parameters: params, encoding: URLEncoding.default)
        .validate()
        .responseJSON

问题是内容类型总是“application / json” 我还尝试将编码设置为URLEncoding.queryString或.httpBody,还尝试将请求的标头设置为标头:[“Content-Type”:“application / x-www-form-urlencoded”]

请提供一些建议,如何在Alamofire 4.0中设置请求内容类型

0 个答案:

没有答案