ActiveCampaign Forum

How to sideload contactField values in /contacts


#1

I’m trying to view the custom field values in the /contacts endpoint but haven’t had any luck. I’ve tried many combinations of ?include=fieldValues, ?include=fieldValues.value but the only thing I’m getting back is an array of numbers, which seems difficult to reconcile with actual fields and values.

I’m able to follow the links to /api/3/contacts/<contact_id>/fieldValues, but this makes it seem that I’m going to have to make an extra request for every contact, which adds massive overhead and latency. I’m sure there’s something I’m overlooking but haven’t been able to figure out. Any help is appreciated!


#2

If you have to read the custom value only for some contact you can use the API v3, you have to do one call to get the contacts, one to get his custom fields and then one to obtain the custom field names from each fields’ id (you can memorize a map <id, custom field name> and use it to parse the fields’ id if you want to save some call)

If you have to read the custom value of many contacts you can use the API v1 endpoints, like “contact_list” or “contact_view”, in the API v1 when you retrieve a contact you can directly read his “fields” array, for each element you can read its name in the field “title” and its value in the field “val”.

it is a bit of a workaround i was not able to find a way to make it with a single call using the API v3 :thinking:
Hope it can be of some help