I am trying to make make a RingOut call with RingCentral using their RingCentral SDK. I am basically following their tutorial found here:
https://developers.ringcentral.com/guide/voice/quick-start/c-sharp
Other than the fact that I'm trying to do this in an MVC web app and not in a console app my code basically looks identical to theirs:
public async Task<JsonResult> Call(string number)
{
var rc = new RestClient(RingCentralCredentials.ClientId, RingCentralCredentials.ClientSecret, false);
var tokenInfo = await rc.Authorize(RingCentralCredentials.Username, RingCentralCredentials.Extension, RingCentralCredentials.Password);
// The above line throws the exception.
var parameters = new MakeRingOutRequest();
parameters.from = new MakeRingOutCallerInfoRequestFrom { phoneNumber = RingCentralCredentials.Username };
parameters.to = new MakeRingOutCallerInfoRequestTo { phoneNumber = number };
parameters.playPrompt = false;
var resp = await rc.Restapi().Account().Extension().RingOut().Post(parameters);
return Json(resp.status, JsonRequestBehavior.AllowGet);
}
yet for some reason when I run this code I get the following error when the execution gets to the Authorization line:
Cannot access a disposed object.
Object name: 'System.Net.Http.FormUrlEncodedContent'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Http.FormUrlEncodedContent'.
Does anyone have any advice with regards to this? The SDK version I'm using is 1.2.1: