Search code examples
xml-rpcinfusionsoft

How to retrieve Contact from InfusionSoft XML-RPC API?


I am attempting to access the contact information from InfusionSoft. I have had a lot of success with their REST API but I need to use the XML-RPC API for some fields.

I am using the package "infusionsoft-client" https://github.com/theY4Kman/infusionsoft-client

The example that they provided works to add a contact. However, when I try to retrieve the contact information I cannot seem to format it correctly.

Here is what I have tried.

infusionsoft.ContactService.load({'contactId': 1, 'selectedFields': ('FirstName', 'LastName')})
infusionsoft.ContactService.load({'contactId': 11, 'selectedFields': 'FirstName', 'LastName'})
infusionsoft.ContactService.load({'contactId': 11, 'selectedFields': ['FirstName', 'LastName']})
infusionsoft.ContactService.load({'contactId': 11, 'selectedFields': "['FirstName', 'LastName']"})
infusionsoft.ContactService.load({'privateKey': <my_key>, 'contactId': 11, 'selectedFields': ['FirstName', 'LastName']})
infusionsoft.ContactService.load({'privateKey': <my_key>, 'contactId': 1, 'selectedFields': ('FirstName', 'LastName')})
infusionsoft.ContactService.load({'privateKey': <my_key>, 'contactId': 11, 'selectedFields': 'FirstName', 'LastName'})
infusionsoft.ContactService.load({'privateKey': <my_key>, 'contactId': 11, 'selectedFields': ['FirstName', 'LastName']})
infusionsoft.ContactService.load(<my_key>, {'contactId': 11, 'selectedFields': ['FirstName', 'LastName']})

I'm not sure what I am doing wrong here. I have tried formatting it exactly like the docs SAY and also tried the example given in the docs. https://developer.infusionsoft.com/docs/xml-rpc/#contact-retrieve-a-contact


Solution

  • This ended up working.

    infusionsoft.initialize(INFUSIONSOFT_APP_NAME, INFUSIONSOFT_API_KEY)
        args = {"contactId" : "9", "selectedFields":['FirstName', 'LastName', 'Password']}
        contactId = args['contactId']
        selectedFields = args['selectedFields']
        my_contact = infusionsoft.ContactService.load(contactId, selectedFields)