ios - Alamofire 发布请求错误调用中的额外参数 'method'

标签 ios swift xcode alamofire

我正在使用 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/

相关文章:

ios - swift ios 有原生选项菜单吗?

iphone - 如何100%更改iPhone应用程序名称!

ios - 在不停止 f.e. 的情况下在后台使用 AVSpeechSynthesizer音乐应用

ios - CALayer 的一些视觉错误

swift - 如何格式化我的 plist 数组以使其在 tablecell 中看起来不错?

ios - 持久化数据并传递给多个 View

xcode - 如何在Interface Builder中创建 "Reference Bindings"?

ios - 'Code signing' Xcode 6.3 中缺少“配置文件”选项

ios 如何正确使用 NSPredicate 将 NSString 与核心数据匹配?

swift - 快速处理 json 响应 Observable