首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么尝试通过RingCentral SDK进行RingOut调用时会出现“无法访问已处置的对象”错误?

为什么尝试通过RingCentral SDK进行RingOut调用时会出现“无法访问已处置的对象”错误?
EN

Stack Overflow用户
提问于 2019-07-16 07:47:59
回答 1查看 603关注 0票数 1

我正在尝试使用RingCentral的RingCentral开发工具包进行RingOut调用。我基本上是按照他们的教程在这里找到的:

https://developers.ringcentral.com/guide/voice/quick-start/c-sharp

除了我试图在MVC web应用程序中实现这一点,而不是在控制台应用程序中,我的代码看起来与他们的基本相同:

代码语言:javascript
复制
    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行时,我得到了以下错误:

代码语言:javascript
复制
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:

https://www.nuget.org/packages/RingCentral.Net/1.2.1

EN

回答 1

Stack Overflow用户

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57048392

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档