【发布时间】:2017-05-11 18:54:00
【问题描述】:
我正在使用 Swift 3 和 Alamofire 4.0。
我想创建与屏幕截图中显示的 Postman 请求类似的 Alamofire POST 请求:
我已经尝试过使用这些代码行:
var parameters: [String: Any] = [
"client_id" : "xxxxxx",
"client_secret" : "xxxxx",
"device_token" : "xxxx",
"fullname" : "xxxxx",
"gender": "xxx"
]
Alamofire.request(url, method: .post, parameters: parameters).responseJSON { response in
print(response)
}
但是我收到了这个错误:
如何在 Swift 3 中使用 Alamofire 实现将 Body 作为表单数据的 POST 请求?
【问题讨论】:
-
响应序列化有问题。是 JSON 格式的吗?
-
查看错误是指 response 不是有效的 JSON,请尝试先查看响应。 (例如使用查尔斯)