user3766930 user3766930 - 1 month ago 10
iOS Question

Alamofire does not want to accept my parameters in the query - it says extra argument in the call

I wrote a function in

swift
for fetching data based on different parameters. The very beginning of the function is:

func makePostQuery(_ parameters: [String:AnyObject], url: String)
{

Alamofire.request(url, parameters: (parameters), method: .post)
.validate()
.responseJSON { response in

switch response.result {
case .success:


but the problem is that
(parameters)
is highlighted and raises error:

Extra argument `parameters` in call


The parameters for example are constructed like this:

var params = [
"long": lon as AnyObject,
"lat": lat as AnyObject,
"startDate": DateCalc.convertValueToDate(defaults.float(forKey: "startDate")) as AnyObject
] as [String: AnyObject]

Answer

You have a wrong order of parameters. Try this instead:

Alamofire.request(url, method: .post, parameters: parameters)
Comments