Custom fields are not working in REST API

Hi,

We tried to list all of our contacts using the REST API:

https://api.infusionsoft.com/crm/rest/v1/contacts?limit=128&offset=0&order=id&access_token=xxxxxxx&optional_properties=custom_fields

For all the contacts we received, the custom_fields property was null:

custom_fields []

We however have contacts which do have custom fields values. Acording to the documentation page:
https://developer.infusionsoft.com/docs/rest/#!/Contact/listContactsUsingGET

This query should have been returned custom fields for the contacts.

Please help.

Thanks,
Sorin.

It seems our documentation needs a little work in order to be more clear. We’ll work to update that. In the meantime, I hope the following helps.

Custom fields are only available for individual contacts via Retrieve a Contact, using optional_properties. List Contacts does not accept optional_properties and does not return custom fields.

For anyone else who stumbles across this thread trying to figure out how to update or retrieve custom_fields via the REST API. It took me a while to figure out but it does work and works well.

When you start digging around information in your IS instance settings looking at custom fields you’re going to come across this text link: View the field database names (for the API). The info you get in this popup I think refers only to the older XML methods, so if you’re using the REST API and JSON this isn’t for you.

First off you need to find out information about your custom fields. SO assuming you have at least one custom field set up, put some test text in it that you’ll recognise and head over to the developer rest API here: https://developer.infusionsoft.com/docs/rest/#!/Contact/getContactUsingGET
You want to use the ‘Contact > Retrieve a contact’ method, and in the parameters > optional properties field input ‘custom_fields’ (I am also assuming you have a client id and secret set up in mashery so that you can try the interactive api docs - otherwise head over there and set that up first). The result displayed here will give you the IS unique id for each custom field you have set up in your instance as well as the value assigned currently.

Now you know what the id is you can format your Rest Request parameters. The correct format is as follows:

{
    "custom_fields":
    [
        {
            "id": 22,
            "content": "testme"
        }
   ]
}

Note that the id here is an integer and content is a string.

Hope that helps. Good luck!

@James_Jefferson, we also have https://developer.infusionsoft.com/docs/rest/#!/Contact/retrieveContactModelUsingGET and https://developer.infusionsoft.com/docs/rest/#!/Contact/createCustomFieldUsingPOST to get the current Custom Fields directly via the API for Contacts, or add a new one to the application! :slight_smile:

1 Like

Thanks @TomScott Tom, good to know! Appreciate now that more can be done with custom fields via the API, which is great.