question

dave-southern12365 avatar image
dave-southern12365 asked Tyler Liu commented

c# api company directory.

I'm trying to read in the company directory for our entire organization. I have the following code:


var response = rc.Restapi().Account("~").Directory();

response.Contacts();


When I run this, however, response.Contacts is not present in the returned object. I don't see anything else that looks like a listing of directory contacts.


Obviously I'm not going in the right direction. Can anybody point me down the right path?

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
RingCentral C# API is Async.

Please try await rc.Restapi().Account("~").Directory();  or rc.Restapi().Account("~").Directory(). Result;
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

dave-southern12365 avatar image
dave-southern12365 answered
I tried adding the 'await' to the beginning of the call, but C# gives me an error saying DirectoryPath does not contain a definition for 'GetAwaiter'.  

For Result, I don't see that as an available option under Directory().

Do I need to update my SDK or am I missing a using or something?
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
Try await rc.Restapi().Account("~").Directory().Contacts().List();   or await rc.Restapi().Account("~").Directory().Contacts().Get();

You can only await on a verb method such as Get/List/Post
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

dave-southern12365 avatar image
dave-southern12365 answered Tyler Liu commented
Thanks man - that get's me the data.

As an aside, is that constraint about only awaiting verb methods something that RC follows, or is that a general guideline for all webAPI's?
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
In C# async programming, you can only await a method which returns Task or Task<T>.

And in RingCentral API, only those verb methods return Task<T>
0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys