【发布时间】:2017-12-02 11:07:30
【问题描述】:
Alamofire Swift 3.0 Extra parameter in call 中的答案对我不起作用。
将标头设置为nil 可以编译,但我需要["Content-Type", "application/json"]。这里我得到一个方法中的额外参数的错误
如何服用
manager.request(url, method: .get, parameters: parameters).responseJSON {
response in
fulfill(response)
}
}
并发送 JSON 内容类型?
文档显示
Automatic Validation
Automatically validates status code within 200..<300 range, and that the Content-Type header of the response matches the Accept header of the request, if one is provided.
Alamofire.request("https://httpbin.org/get").validate().responseJSON { response in
switch response.result {
case .success:
print("Validation Successful")
case .failure(let error):
print(error)
}
}
我正在使用.responseJSON,但我没有返回 JSON。所以我想我需要发送Content-Type 标头。
【问题讨论】: