Skip to main content

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?

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();
}
}



Thanks, works perfectly.

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

Otherwise entries from last page will not be read.


Reply