1 Reply Latest reply on Sep 19, 2014 11:44 AM by Rick Bergen

    Empty streamPosition but non-zero remainingCount on getMultipleLeads call

      Hi, I made the following SOAP call -

           <!--- Removed -->
                 <leadSelector xsi:type="ns1:LeadKeySelector">

           This is the response I received - 

                <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
                          <!-- 3 leadRecords with email = 'test@test.com' -->

      As you can see, the remainingCount is reported to be 1 but the newStreamPosition is empty. The condition I use to terminate the stream is 'remainingCount == 0'. So the empty newStreamPosition leads to an infinite loop.

      I've temporarily modified the condition to 'remainingCount == 0 OR newStreamPosition is blank'. What's going on here?
        • Re: Empty streamPosition but non-zero remainingCount on getMultipleLeads call
          Rick Bergen
          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.