question

Lev Rakhman avatar image
Lev Rakhman asked Phong Vu edited

API How to get all Directory entries

I am getting initial list of of entries:

var resp = await restClient.Restapi().Account("~").Directory().Entries().List(listDirectoryEntriesParameters);

return object has 2 properties: paging object and array of records.

How do I access all pages in response?

sdk
1 |3000

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

Phong Vu avatar image
Phong Vu answered Phong Vu edited

You can read like this

read_company_directory(-1).Wait();

static private async Task read_company_directory(int pageNumber)
{
  pageNumber++;
  var listDirEntriesParams = new ListDirectoryEntriesParameters();
  listDirEntriesParams.perPage = 300;
  if (pageNumber > 0)
      listDirEntriesParams.page = pageNumber.ToString();
  var response = await rcsdk.Restapi().Account().Directory().Entries().List(listDirEntriesParams);
  Console.WriteLine("Directory");
  Console.WriteLine(JsonConvert.SerializeObject(response.paging));
  if (response.paging.totalPages >= pageNumber)
  {
      read_company_directory(pageNumber).Wait();
  }
}


1 |3000

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

Lev Rakhman avatar image
Lev Rakhman answered

Thanks, works perfectly.

One small error. It should be if (response.paging.totalPages >= pageNumber)

Otherwise entries from last page will not be read.

1 |3000

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

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