RingCentral SDK for .NET Upgrade Guide

Tyler Long
Mar 5 · 3 min read

We just released a new RingCentral SDK for .NET to NuGet:

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

It is currently in beta and will become the new official SDK for all .NET platforms, including the traditional .NET framework for Windows and the latest .NET Core for cross platform.

Here is a full introduction to all the improvements and new features.

In order for developers to upgrade to this new library as soon as possible, we provide this upgrade guide article.

Package Installation

Previously you install the NuGet package ringcentral-csharp-client

Now you should install the package RingCentral.Net instead.

Many of our users did not use PubNub subscriptions which requires a number of dependencies so this has been split out into separate packages. If you need PubNub subscriptions, use the following packages:

Adjusting Code

The new SDK is fairly backward compatible, but there are still some cases where you need to adjust your code a little bit.

TL;DR

Please reference the sample code for the latest best practices.

Exception handling

Previously whenever there was unexpected HTTP response status code, FlurlHttpException will be thrown. Now RestException will be thrown instead. More information please reference this test case.

Token management

Previously, the SDK starts a background timer to refresh token for you. But it has problems: if you rely on this timer to do token management for you, you need to keep the SDK instance running 24*7, which is impossible for lots of user cases. For serious projects, you may want to create cron jobs to do token refresh and other token management tasks. Now there is no more background timers to refresh tokens magically. You need to do token management yourself and you have full control over it. More information please reference this test case.

Please note that theTokenRefreshed event has been removed because token management is controlled by developers completely.

No more anonymous types

You need to adjust your code where you use anonymous types. And your IDE will tell you what specific types you will need instead.

So instead of

var callLogResponse = await rc.Restapi().Account().CallLog().List(new
{
perPage = 3,
dateFrom = DateTime.UtcNow.AddMonths(-6).ToString("o")
});

You need to specify type:

var callLogResponse = await rc.Restapi().Account().CallLog().List(new LoadCompanyCallLogParameters
{
perPage = 3,
dateFrom = DateTime.UtcNow.AddMonths(-6).ToString("o")
});

Don’t worry you don’t need to memorize those types or check manuals. Because your IDE will tell you what types are required.

PubNub subscription

There are minor changes to PubNub subscription code, in order to be more consistent with SDKs in other programming languages. For more information , please read this test case.

Dealing with binary

We made minor changes to binary handling, including uploading new profile image, downloading call recording…etc. We made the changes just to make all the binary handling code more consistent. For more information and latest code samples, please reference these test cases.

Array type query parameters

Some query parameters allow multiple values. Previously the SDK couldn’t handle it properly. Now it is fully supported. So instead of

await addressBook.Contact()
.List(new ListContactsParameters() {phoneNumber = phoneNumber});

You need to

await addressBook.Contact()
.List(new ListContactsParameters() {phoneNumber = new[] {phoneNumber}});

The advantage is the latter allows you to specify multiple values.

TTL support

You probably don’t need to know this, because most of the time default TTL is fine. If you do need change TTL (time to live) of access token and refresh token, please check these test cases. It’s slightly different from old way.

Parameter renaming

We rename some of the parameters so they make more sense. For example: CallLogPath.ListParameters has been renamed to LoadCompanyCallLogParameters. In order to upgrade, you simply need to use the new type name instead of the old name, no other actions are required.

RingCentral Developers

Cloud Business Communications

Tyler Long

Written by

RingCentral Developers

Cloud Business Communications

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade