加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

[Swift,Alamofire]:responseValidationFailed,错误代码为400

发布时间:2020-12-14 04:48:32 所属栏目:百科 来源:网络整理
导读:我的问题基本上在标题中.我试图运行的代码就在下面. VVV let unfollow = "https://api.instagram.com/v1/users/(userID)/relationship?access_token=(access_token)action=unfollow" Alamofire.request(unfollow,method: .post).validate().responseJSON(c
我的问题基本上在标题中.我试图运行的代码就在下面. 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也.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读