question

dew8601 avatar image
dew8601 asked dew8601 answered

C# Authorization 400 - Bad Request

I'm using the latest official C# SDK in a new ASP.NET Core 2.0 web application. Although the SDK isn't built to the same target framework, the app compiles and seems ok. I've tried just about every setting (public/private, web, web/ui, etc.) but I always get the following error:


FlurlHttpException: Request to https://platform.devtest.ringcentral.com/restapi/oauth/token failed with status code 400 (Bad Request).


I'm using simple code which appears the same as the SDK sample:


var restClient = new RestClient(appKey, appSecret, appUri);

await restClient.Authorize(userName, extension, password);


If you're able to look up my account info to verify, the sandbox values I'm using are:

  1. appKey = f6v********-61******kw
  2. appSecret = JR****u_QG**************TxA
  3. appURI = https://platform.devetest.ringcentral.com
  4. userName = +1313*****01
  5. extension = 101
  6. password = 1rc********st!

All the above are from the sandbox app credentials. I wish I received something more back, but I just get "400 (Bad Request)". I'm sure it's something dumb I'm doing, it is rather confusing figuring out what values are needed when they are called different things in different places.


Any help is greatly appreciated, I've scoured the community forum and the web. It seems that this error is generally from people not using the sandbox credentials, or the wrong password, but I've changed the sandbox password a zillion times, to no avail.


Thank you!

getting started
1 |1500 characters needed characters left characters exceeded

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

dew8601 avatar image
dew8601 answered
And of course, about 2 minutes after I post this it starts working, lol.  Go figure.

Sorry to be a pest.


1 |1500 characters needed characters left characters exceeded

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

Phong Vu avatar image
Phong Vu answered
Isn't it because of the wrong appURI  https://platform.devetest.ringcentral.com? The correct one is  https://platform.devtest.ringcentral.com 

+ Phong
1 |1500 characters needed characters left characters exceeded

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

dew8601 avatar image
dew8601 answered
No, I just fat fingered that here, it was set properly in my code.  Either way, it's working now, every time, so I'm not going to fret :)
1 |1500 characters needed characters left characters exceeded

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

etam-singh8884 avatar image
etam-singh8884 answered
How is it work now.Can you please explain
1 |1500 characters needed characters left characters exceeded

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

dew8601 avatar image
dew8601 answered
My code is pretty simple:

var restClient = new RestClient(appKey, appSecret, appUri);
await restClient.Authorize(userName, extension, password);            
var requestBody = new
      {
             text,
             from = new { phoneNumber = from },
             to = new object[] { new { phoneNumber = to } }           
      };
var rcExtension = restClient.Restapi().Account().Extension();
var response = await rcExtension.Sms().Post(requestBody);
if (response.messageStatus == "Queued" && response.deliveryErrorCode == null)
{
      return true;            
 }
 else
 {
       return false;
 }

The arguments/vars of 'appKey', 'appSecret', 'appUri', 'userName', 'extension' and 'password' are passed in from my appsettings.json and 'from', 'to', and 'text' are passed in from the caller.  All would obviously need set by you.
1 |1500 characters needed characters left characters exceeded

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