ServiceAPI - page through the entire result set

There are a few parameters that assist you in paging through an entire pageSet.  If you have a good connection to the workgroup server (e.g. server to server) then make the pageSize larger rather than smaller.  The response property HasMoreItems will return false when you are finished.  The sample below assumes basic authentication, check out the ServiceAPI documentation for other authentication methods.

Sample 

TrimClient trimClient = new TrimClient("http://localhost/ServiceAPI");
trimClient.AlwaysSendBasicAuthHeader = true;
trimClient.UserName = "MY_USER_NAME";
trimClient.Password = "MY_PASSWORD";

int pageSize = 50;
bool hasMore = true;

Records request = new Records()
{
    q = "all",
    Properties = new PropertyList(PropertyIds.RecordTitle),
    pageSize = pageSize,
    start = 1
};

while (hasMore)
{                          
    RecordsResponse response = trimClient.Get<RecordsResponse>(request);

    hasMore = response.HasMoreItems;
    request.start = request.start += pageSize;

    foreach (Record record in response.Results)
    {
        Console.WriteLine(record.Title);
    }
}
Written on July 28, 2016