Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 获取请求状态代码:400 Swift_Json_Swift_Oauth_Alamofire - Fatal编程技术网

Json 获取请求状态代码:400 Swift

Json 获取请求状态代码:400 Swift,json,swift,oauth,alamofire,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

我收到代码错误**状态代码: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结果成功,但为什么不显示我的数据

实际上,我得到了带有使用者密钥、使用者密钥、令牌密钥和令牌密钥的请求方法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???

请记住:

400错误请求:服务器无法或将不会处理该请求 由于被认为是客户错误的原因(例如。, 请求语法格式错误,请求消息帧无效,或 欺骗请求路由)


为了更好地理解检查:

通常状态代码400表示您的查询有问题。您的请求可能已成功,但服务器告诉您无法访问数据。从我的代码,哪一个错误,先生?不,不,我不是说您的代码不正确。您发送的数据可能有问题。可能在您的标题或url参数中。可能您有阿拉莫菲尔和Oauth sir方法get的参考文档?please@MendaFernanda在这里查看阿拉莫菲尔官方文件嘿,阿赫拉夫!如何检测无效请求的原因?