我正在使用alamofire进行卷曲 -
curl https://yoursite.desk.com/api/v2/customers \
-u email:password \
-X POST \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"first_name":"John","last_name":"Doe"}'
当我传递用户名和密码时,它适用于curl但不适用于alamofire -
Alamofire.request(.POST, API_END_POINT, parameters: parameter)
.authenticate(user: user, password: password)
.responseJSON(options: NSJSONReadingOptions.MutableContainers) {
(request, response, data, error) in
print(error)
print(data)
}
我总是遇到Unauthenticated
错误。看似它永远不会验证用户和密码。