我的问题基本上在标题中.我试图运行的代码就在下面. VVV
let unfollow = "https://api.instagram.com/v1/users/\(userID)/relationship?access_token=\(access_token)&action=unfollow" Alamofire.request(unfollow,method: .post).validate().responseJSON(completionHandler: { response in switch response.result { case .success(let value): let data = JSON(value)["data"] print(data["outgoing_status"].stringValue) case .failure(let error): print(error) } })
我收到的确切控制台错误是:responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(400))
我顺便使用Instagram API,但我认为这不一定与问题有关.
任何帮助非常感谢.
解决方法
错误日志responseValidationFailed(Alamofire.AFError.ResponseValidationFailureReason.unacceptableStatusCode(400))清楚地表明您收到400错误.这在
W3.org中解释为
400 Bad Request:
The request Could not be understood by the server due to malformed Syntax. The client SHOULD NOT repeat the request without modifications.
因此,如果正确,您需要请求URL请求URL.
此外,您正在使用请求的validate()方法,该方法应该获得响应状态代码200 … 299,但您将获得400作为响应代码.这就是为什么它在错误日志中被提及为不可接受的StatusCode(400).
Seel this也.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。