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.

Hi Tom, this method works for custom fields in contacts, how do you read custom fields in the ORDERS api?

Is this for me?

image001.jpg

Bob Howard Founder & President

Contact Science

7265 Claiborne Drive | Germantown, TN 38138

901-327-8686

Book A Meeting: https://calendly.com/contactscience/bookameeting

web meetings - click: https://global.gotomeeting.com/join/145186906 AND THEN, call in using your telephone – (213) 493-0618 and use Access Code: 145-186-906

Hi Bob

I was asking Tom Scott if there was a way to read custom fields from ORDERS rest api

If you happen to know the answer I would love to hear it, I have a feeling for some crazy reason it was never implemented

Unfortunately we do not have Custom Fields enabled on all endpoints, but it’s possible to use your same Access Token to call the XML-RPC API and get the data from the DataFormFields (internal name for Custom Fields).

https://developer.infusionsoft.com/docs/xml-rpc/#data-query-a-data-table
https://developer.infusionsoft.com/docs/table-schema/#DataFormField

Is there a way, currently, to update a contact’s “optional_properties”? I am able to retrieve a contact’s optional properties, but have not figured out a way to update them via the api.

Specifically I am looking to update “company_name” which is listed under optional_properties. It doesn’t have the same structure as custom_fields so there must be a different way to update this via the api.