我正在使用 xcode 9.2 我想发出一个发布请求但是我收到这个错误“调用中的额外参数‘方法’”。我知道这是在谈论 post 方法,但我不知道如何解决它,有人可以帮忙吗?
Alamofire.request(URL_REGISTER, method: .post, parameters: body, encoding: JSONEncoding, headers: header).responseString {
(response) in
if response.results.error == nil {
completion(true)
} else {
completion(false)
debugPrint(response.resultd.error as Any)
}
}
最佳答案
您的属性可能无效(如果类型不匹配,Xcode 将使用最接近的匹配函数告诉您错误)
尝试将 JSONEncoding
更改为 JSONEncoding.default
并且您的 body
匹配 [String:Any]
Alamofire.request(String, method: HTTPMethod.post, parameters: [String:Any], encoding: JSONEncoding.default, headers: header)
沿着这些线的东西(我不知道标题属性我通常在 nil
有这个)
关于ios - Alamofire 发布请求错误调用中的额外参数 'method',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49517466/