Use REST API to access custom fields via labels rather than numbers

Hi there…

Is there a way to access the custom fields via the rest api by their names rather than their Id’s? I am able to access the custom fields via their index numbers however when I added or deleted custom fields, all of their id’s were re-numbered.

I did see a post where someone is using a loop to go through all of the custom fields and identify the appropriate Id by comparing the label contents - however this seems clunky.

Any other suggestions?

thanks!

Hi @leonardo_cutone, the issue with accessing custom fields via their label is that it’s not a unique value, more than one custom field can share the same label.

Would a filter parameter for the label filed on the list contact custom fields endpoint be helpful?

Hi thanks for responding —— a filter parameter - if that works then I’ll take it. Is there an example of how this is done ?

This filter doesn’t currently exist but I’ve added a story to our backlog so we can work on it.

Alternatively you could search for custom fields by label right now using XML-RPC’s DataService.query method. Here’s an example request:

<?xml version='1.0' encoding='UTF-8'?>
<methodCall>
  <methodName>DataService.query</methodName>
  <params>
    <param>
      <value><string>{{privateKey}}</string></value>
    </param>
    <param>
      <value><string>DataFormField</string></value>
    </param>
    <param>
      <value><int>100</int></value>
    </param>
    <param>
      <value><int>0</int></value>
    </param>
    <param>
      <value>
        <struct>
          <member>
            <name>FormId</name>
            <value><int>-1</int></value>
          </member>
          <member>
            <name>Label</name>
            <value><string>YOUR_LABEL</string></value>
          </member>
        </struct>
      </value>
    </param>
    <param>
      <value>
        <array>
          <data>
            <value><string>Id</string></value>
            <value><string>Name</string></value>
            <value><string>Label</string></value>
            <value><string>DataType</string></value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodCall>

Thank you

Okay I’ll try this -
So this is not a rest call then?

If I use the Rest/Json method would the for loop on the label names work? If you are gonna phase out the xml methods then I would rather develop on the future protocols

Correct, this is using our legacy XML-RPC API. I’m not sure of the time frame for when XML-RPC will be sunset but I don’t imagine it being anytime soon.

Looping over the results from the REST endpoint will also work.

@Nicholas_Trecina - question to add to this. When I use a system like Zapier or Workato, they are able to pull custom field names instead of field ID’S. how are they doing this?

They are using the Legacy XML-RPC API, and specifying the Label of the DataFormField (internal name for custom fields) to return as shown above in @Nicholas_Trecina comment.