我正在使用Swift 3和Alamofire 4.0。发布方法请求Alamofire
我想创建一个类似于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格式吗? –
看看这个错误,它指的是*响应*不是一个有效的JSON,试着先看看响应。 (如使用查尔斯) –
http://stackoverflow.com/questions/31982513/how-to-send-a-post-request-with-body-in-swift –