News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
C# Authorization 400 - Bad Request
Tags: getting started
Jan 24, 2018 at 6:03am   •   5 replies  •  0 likes
dew

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!

5 Answers
answered on Feb 14, 2018 at 6:38am  
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.

 0
answered on Feb 14, 2018 at 6:13am  
How is it work now.Can you please explain

 0
answered on Jan 24, 2018 at 7:50am  
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 :)

 0
answered on Jan 24, 2018 at 7:37am  
Isn't it because of the wrong appURI https://platform.devetest.ringcentral.com? The correct one is https://platform.devtest.ringcentral.com 

+ Phong

 0
answered on Jan 24, 2018 at 6:10am  
And of course, about 2 minutes after I post this it starts working, lol.  Go figure.

Sorry to be a pest.



 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us