question

dave-southern12365 avatar image
dave-southern12365 asked ·

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?
General Topic
1 |1500 characters needed characters left characters exceeded

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 |1500 characters needed characters left characters exceeded

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 |1500 characters needed characters left characters exceeded

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 |1500 characters needed characters left characters exceeded

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 ·
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 |1500 characters needed characters left characters exceeded

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

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 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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