API and custom fields - how to reference them in $select or $filter
Hi. According to some of the documentation it implies that I can use a custom fields' name to reference it. I can directly reference common fields as a $select parameter, but can only reference other fields using their custom-xxx tag, like this:
'$select' => 'First name, Last name, Email, custom-8097667,
custom-8097668, custom-8161502, custom-8097675, custom-8017535'
The custom field tag does not seem to appear anywhere in Membership fields area of the WA database though so the only way I can find it out is by trawling through json data manually.
Is there a better way to reference those fields, or to find out their custom-xxx reference (as I've mentioned, I've looked through the WA membership fields in the actual WA site and can see no obvious use of this custom-xxx referencing). The code snip below is part of the json returned on a full dump, and SystemCode is the only place that I can see that references the custom field number:
json data referencing a custom field:
 => Array
[FieldName] => Practice Address 1
[Value] => 40 Test Way
[SystemCode] => custom-8097667
Thanks Dmitry. contactFields call is useful. I think I'd tried field name but wrapped in double-quotes, which as you say, fails. This should help!
if you want to get fields metadata, then make an API call to /v2.1/accounts/XXX/contactfields
This will return a lot of information about configured contact fields.
There are 2 possible ways to address a field: by field name or by system code.
If you work with system codes you can be sure that it can't eventually be changed. If you work with field name, then changes in UI could affect your integration code.
How to use $select and $filter parameters:
1. Use Field name or system code, both of them will be understood by API
2. Enclose field names in single quotes. This symbol ' - OK. These symbols " ′ ‘ ’ will not work.
Here is an example:
$filter='First name' eq 'John' and 'Age' gt 21
$select='First name','Last name',Phone