Skip to main content
New Participant
May 1, 2017
Question

RestClient::BadRequest: 400 Bad Request

I am getting a RestClient::BadRequest: 400 Bad Request when hitting the endpoint "/restapi/oauth/token"


Here is my code.


 def get_new_tokens                   url = "#{BASE_URL}/restapi/oauth/token"
  hash = {
   grant_type: "password",
   username: username,
   password: password,
   extension: extension
  }
  response = JSON.parse(RestClient.post(url, hash, self.class.headers))
  puts response
  self.update(
   access_token: response['access_token'],
   refresh_token: response['refresh_token'],
   expires_at: DateTime.now + response['expires_in'].seconds,
   refresh_token_expires_at: DateTime.now + response['refresh_token_expires_in'].seconds,   
  )
 end  


I cant figure out what the issue is. I am not getting any description back on the 400 error. Any help would be much appreciated.

1 reply

Employee
May 2, 2017
Could you please post the message body? HTTP status code alone is not very helpful.

By the way, are you using any SDK or writing HTTP code yourself?