Alamfire принимает [String:Any]
do {
let params = try JSONSerialization.jsonObject(with: data, options: []) as! [String:Any]
Alamofire.request(url, method: .post, parameters:params, encoding: JSONEncoding.default, headers: headers)
request.validate().responseJSON {
...
}
}
catch {
print(error)
}
Swift 4.2
Alamofire.request(url, method: .post, parameters: [:], encoding: "test", headers: [:])
extension String: ParameterEncoding {
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
var request = try urlRequest.asURLRequest()
request.httpBody = data(using: .utf8, allowLossyConversion: false)
return request
}
}