question

jordan-graft5285 avatar image
jordan-graft5285 asked Tyler Liu answered

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.

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Tyler Liu avatar image
Tyler Liu answered
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?
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys