【发布时间】:2016-06-11 01:15:49
【问题描述】:
我是 IOS 开发领域的新手,我正在使用 swift 和 Alamofire 开发一个应用程序。我需要调用一个返回会话令牌的服务端点才能登录到我的应用程序:
Alamofire.request(.POST, url, parameters: ["grant_type": "password", "username": "myusername", "password": "mypassword"], encoding: .JSON).validate().responseString { response in
switch response.result {
case .Success:
onSuccess()
case .Failure(let error):
onError(error)
}
}
这个Api调用的响应是成功的,但是我总是得到{"error":"unsupported_grant_type"}而不是得到token信息。
请指教。
【问题讨论】:
-
如果您更改为编码:.URL(对于 application/x-www-form-urlencoded 标头)会发生什么?
-
是的,可以,非常感谢。
标签: ios swift web-services rest alamofire