获取请求状态代码:400 Swift

时间:2017-04-11 07:53:53

标签: json swift oauth alamofire

我收到代码错误**状态代码:400 *

URL: https://conversation.8villages.com/1.0/contents/articles?state=published } 
{ status code: 400, headers {
Connection = "keep-alive";
"Content-Length" = 2;
"Content-Type" = "application/json";
Date = "Tue, 11 Apr 2017 07:49:13 GMT";
Server = nginx;

} }
2 bytes
SUCCESS
JSON: {

}

我的json是结果SUCCESS但是没有显示我的DATA?

实际上我得到了消费者密钥,消费者秘密,令牌密钥和令牌密钥的请求方法Alamofire。像这样:

    let params: HTTPHeaders = ["oauth_consumer_key":"*****",
                               "oauth_consumer_secret":"*****",
                               "oauth_token_key":"*****.",
                               "oauth_token_secret": "*****",
                               "oauth_signature_method": "HMAC-SHA1",
                               "oauth_timestamp_key" : "1491366048",
                               "oauth_version": "1.0"] as [String : Any] as! HTTPHeaders;

    Alamofire.request("https://conversation.8villages.com/1.0/contents/articles?state=published", method: .get, headers: params).responseJSON { response in
        print("test", response.request!)  // original URL request
        print("ini responseny", response.response!) // HTTP URL response
        print("test", response.data!)     // server data
        print("test", response.result)   // result of response serialization

        if let JSON = response.result.value {
            print("JSON: \(JSON)")
        }
    }

如何获取我的数据API ??

1 个答案:

答案 0 :(得分:0)

请记住:

  

400错误请求:服务器无法或不会处理请求   由于被认为是客户端错误的东西(例如,   格式错误的请求语法,无效的请求消息框架或   欺骗性请求路由)。

为了更好地理解检查:this