0

i got code error **status code: 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: {

}

my json is result SUCCESS but wht not show my DATA?

actually i get request method Alamofire with Consumer Key, Consumer Secret, Token Key and Token Secret. like this :

    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)")
        }
    }

how to get my data API ??

  • Usually status code 400 indicates that there is something wrong with your query. Your request might have been successful but the server is telling you that you can't access the data. – Zonily Jame Apr 11 '17 at 08:10
  • from my code, which wrong sir? – Menda Fernanda Apr 11 '17 at 08:44
  • No no, I didn't mean that your code is incorrect. There just might be something wrong with the data your sending. probably in your headers or your url parameters. – Zonily Jame Apr 11 '17 at 08:45
  • maybe you have reference documentation for method get for Alamofire and Oauth sir? please – Menda Fernanda Apr 11 '17 at 09:09
  • @MendaFernanda Check the official Alamofire documentation here https://github.com/Alamofire/Alamofire/tree/master/Documentation – ashxvi Apr 11 '17 at 09:19

1 Answers1

0

Please keep in mind :

400 Bad Request : The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).

For a better understanding check : this

Community
  • 1
  • 1
ashxvi
  • 144
  • 1
  • 10