Skip to main content
Question

RestClient::BadRequest: 400 Bad Request

  • May 1, 2017
  • 1 reply
  • 687 views

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

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?