我正在尝试使用他们的 RingCentral SDK 与 RingCentral 进行 RingOut 通话。我基本上遵循他们在此处找到的教程:
https://developers.ringcentral.com/guide/voice/quick-start/c-sharp
除了我试图在 MVC Web 应用程序中而不是在控制台应用程序中执行此操作之外,我的代码基本上与他们的代码相同:
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);
}
但是由于某种原因,当我运行此代码时,当执行到达授权行时出现以下错误:
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'.
有人对此有什么建议吗?我使用的 SDK 版本是 1.2.1: