This content has been marked as final. Show 1 reply
I've found that if the returnCount is less than the batchSize I can conclude that there are no more records to get despite the remainingCount being greater than zero. The remainingCount is notoriously unreliable with the excuse being it is an "estimate". I vaguely recall the errors in remainingCount may have something to do with Marketo including SFDC Users in their remainingCount but not at their returned results.
This is the hack I put in my code to avoid the somewhat infinate loops I was getting:
if (returnCount < batchSize)
remainingCount = 0;
A better solution may indeed be to look for a blank newStreamPosition as you have suggested as I suppose having exactly a batch size of records is possible.