我正在尝试使用RingCentral的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);
}然而,由于某些原因,当我运行这段代码时,当执行到Authorization行时,我得到了以下错误:
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:
发布于 2019-07-18 01:45:34
本教程中的原始应用程序是控制台应用程序。你也可以用控制台应用重现这个问题吗?或者这只是一个web应用程序的问题?我看到你开了一个RingCentral支持案例。我会在那个支持案例中回复你。一旦我们找到了根本案例,我会在这里发布更新。
我已经尝试过Marko提供的示例代码,我想我已经找到了根本原因。当我们尝试通过密码进行授权时,正在使用的RingCentral应用程序不允许密码流。有关此问题的更多信息,请访问:https://forums.developers.ringcentral.com/questions/452/http-400-unauthorized-for-this-grant-type.html
https://stackoverflow.com/questions/57048392
复制相似问题