private void ReadDefects(List<ALMItem> items)
{
int startIndex = 0;
int pageSize = 100;
int total = 0;
do
{
RestRequest getDefects = new RestRequest(clientConfig.EntitiesAddress);
AddDomainAndProject(getDefects);
AddDefect(getDefects);
getDefects.AddHeader("Accept", "application/xml");
getDefects.AddParameter("page-size", pageSize);
// start index appears to be 1-based, despite the documentation on https://MYDOMAIN.saas.hp.com/qcbin/Help/doc_library/api_refs/REST/webframe.html
getDefects.AddParameter("start-index", startIndex + 1);
IRestResponse response = Execute(getDefects, "get defects");
XDocument doc = XDocument.Parse(response.Content);
total = FindTotal(doc);
foreach (var entity in doc.Root.Elements())
{
items.Add(ALMItem.FromXML(entity.Elements("Fields").Elements()));
}
// time for the next page
startIndex += pageSize;
} while (startIndex < total);
}