1

I'm trying to use the API docs for SalesforceIQ (here: https://api.salesforceiq.com/#/python) to retrieve all of my Contact objects. As is, I'm only getting the first 200. I'm doing this:

def get_all_contacts():
    contacts = Contact().fetchPage()
    return contacts

I want to get ALL of the Contact objects, though. How would I go about this?

4

To add to Adrian's answer, you need to run a loop until you there're no more records left to be retrieved in batches of 200. Something along these lines (check the exact syntax based on Python version/ framework you use)

def get_all_contacts():
    startIndex = 0
    limit = 200
    allContacts = Contact().fetchPage(startIndex,limit)
    moreContacts = allContacts
    while moreContacts is not None
        startIndex + = limit
        moreContacts = Contact().fetchPage(startIndex,limit)
    allContacts.append(moreContacts)
    return allContacts
  • Should it be moreContacts += Contact().fetchPage(startIndex, limit) – bclayman Jun 9 '16 at 15:41
  • Yes, you can do that as well! – Gaurav Kheterpal Jun 9 '16 at 20:51
1

From the documentation you link, the optional _limit parameter has a maximum value of 200 when getting all records from a list.

Get All List Items

_limit
[Numeric]
An optional page size for the returned result (defaults to 50, max size is 200).

  • Thanks for the reply. How would you recommend I go about getting all Contact objects then? Is there a way to get the "2nd" batch of 200? Thanks for the help! – bclayman Jun 7 '16 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.