0

I'm attempting to read all the journals associated with the Demo UK company however I repeatedly end up with the same data. I'm calling the journals endpoint multiple times but I seem to end up with the same data. From the API documentation:

A maximum of 100 journals will be returned in any response. Use the offset or If-Modified-Since filters (see below) with multiple API calls to retrieve larger sets of journals

Code snippet I use to get all the journals is as seen below - I reckon it is a beginner mistake but any help/guidance is appreciated.

List<Journal> batchJournals;
List<Journal> allJournals = new List<Journal>();
int skip = 0;
var journalsEndPoint = m_api.Journals.Offset(skip);


while((batchJournals = journalsEndPoint.Find().ToList()).Count > 0)
{
    allJournals.AddRange(batchJournals);
    skip += batchJournals.Count;
    journalsEndPoint = journalsEndPoint.Offset(skip); //Get the next 100 journals
}
rahul
  • 407
  • 1
  • 6
  • 20

1 Answers1

0

Just came across this and noticed nobody had answered. You've probably figured this out by now. The journal numbers on the demo company may not start at zero so depending on what your first journal number is you could get the same data back each time. For real Xero organisations journals will always start at 1.

byJeevan
  • 3,728
  • 3
  • 37
  • 60
DevXDan
  • 3
  • 2