Mirza Delic Mirza Delic - 1 year ago 147
Swift Question

Alamofire extra argument 'method' in call

I use

Alamofire
4.0.1 and have this code:

let params = Mapper().toJSON(group)

Alamofire.request("\(Config().apiAdminTableGroup)\(group.id)/", method: .put, parameters: params, headers: Config().apiHeaders, encoding: JSONEncoding.default)
.responseJSON { response in
...
}


But getting this error:


Extra argument 'method' in call


This is by documentation, is this bug or?

Answer Source

Check that the structure of your parameters and headers are right, if not the error you mentioned appears. It should look like that:

Alamofire.request("\(Config().apiAdminTableGroup)\(group.id)/", method: .put, parameters: ["param1":"1", "param2":"2"], encoding: JSONEncoding.default, headers: ["Authorization": "Basic xxx"])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download