Alamofire extra argument 'method' in call

孤街醉人 提交于 2019-12-11 06:06:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!