问题
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?
回答1:
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"])
回答2:
try this:
Alamofire.request(.PUT, "\(Config().apiAdminTableGroup)\(group.id)/",
parameters: params).responseJSON { response in
...
}
来源:https://stackoverflow.com/questions/40181731/alamofire-extra-argument-method-in-call