c# api company directory.

  • 1
  • Question
  • Updated 2 weeks ago
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?
Photo of Dave Southern

Dave Southern

  • 110 Points 100 badge 2x thumb

Posted 2 weeks ago

  • 1
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,492 Points 5k badge 2x thumb
RingCentral C# API is Async.

Please try await rc.Restapi().Account("~").Directory();  or rc.Restapi().Account("~").Directory().Result;
Photo of Dave Southern

Dave Southern

  • 110 Points 100 badge 2x thumb
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?
(Edited)
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,492 Points 5k badge 2x thumb
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
Photo of Dave Southern

Dave Southern

  • 110 Points 100 badge 2x thumb
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?
Photo of Tyler Long

Tyler Long, Official Rep

  • 8,412 Points 5k badge 2x thumb
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>