Looking up values in custom contact field with REST V2 API

I’ve seen this question answered for V1 and in xmlRpc, but I’m needing to figure this out using the new REST V2.

I can actually update my custom fields as I know their ids, but I’m not rather new to working with REST and I’m not sure what I should be doing to get a contact by a value in the custom field.

Thanks!

i think you will use two api calls, one to List Contacts and another Retrieve a Contact with contact id and filter the contact with your custom field value

Thanks for the input. I really don’t want to do that as it means moving all the data to a client app to search for the key to the one record I want.

That approach would be impossible if there were 10s of thousands of records to look through.

yea i agree that not the best option with REST API V2 but i think its the only option right now, i suggest use REST API V1

i just test you can use query parameter ‘optional_properties’ => custom_fields in REST API V2 call and it will return the custom fields also

Getting the custom_fields can be done using the fields parameter.

What I’m trying to do is filter the query based on the value of one of the custom_fields.

We do not currently index custom field values for filtering due to system constraints.

Do you know if this ever got updated? Are custom fields indexed now?

No, Custom Fields are currently not indexed. This is not a defect, but a constraint based on how they are stored, retrieved, and the various types of data contained in them.

So if I wanted to look up a contact based on a custom field value I can’t do that?

Find ContactID for CutomFieldID4 when data equals string?

Is this not possible?

@TomScott, it is looking like that the REST V2 API is not going to be comparable to the XML-RPC API.

If I run a Custom Field search it takes a couple of seconds to return the results back via the XML-RPC. I am wondering why it is an issue to implement that functionality into REST? You can make changes to your platform to support it.

There are integrations out there that will require searching by Custom Fields, and i have also done that myself. In the future you plan to deprecate the XML-RPC API, so how are developers going to easily make that change to REST?

The only viable solution for REST would be to pull all the contact data into a local database, and run a search for the Custom Field in there. But that requires regularly pulling the data from Keap every time.

I agree Pav. It’s a little scary that the word is the XML-RPC API will be removed at some point when there aren’t any ways to do some things in REST v1 or REST v2. For example, I just did a bunch of updates from legacy code where they needed to send an email. That can only be done via the XML-RPC API. Same for searching by custom field (which I also needed to do for this same update), and also to run an Action Set. ALL of those had to be done via XML-RPC (and yes, I know I could change it to a tag or api goal instead of action set, then put the action set into a campaign triggered by the tag or api goal … but … :slight_smile: I’m just concerned that this was all done prematurely to have everyone update legacy code JUST SO THEY WILL HAVE TO DO IT AGAIN because the newer APIs are still not ready (which is the reason I never switched to the new APIs before now …)

Any update on this based on what @Pav said above? I’m looking to rebuild an application that is built using XML-RPC that performs a search to identify a contact based on one of the values of their custom fields.

i.e. I’m looking to retrieve a Keap user that has a particular serial number associated with it in a custom field without knowing anything else about that user in Keap.

This seems to be possible with the XML-RPC API which is what we were using before. Is there any timeline for when we can expect parity between the two? We’ve currently updated to the new authentication method, but hopefully before XML-RPC is sunsetted we can do these things.

Thanks,
Nathan.

Hi @Brian_Quimby, @pagedesigner, @MarcPSummers, @Pav, @Nathan_Donnelly and @geekgoddess.

Custom field filtering is now available in REST v2 for the following resources:

  • Contacts

  • Companies

  • Orders

  • Affiliates

For these supported resources, custom fields can be filtered just like any other field using the filter parameter.

Some highlights:

  • Filter custom fields by their field name (case-insensitive, as returned by GET /v2/{resource}/model).

  • Support varies by field type:

    • Text-like fields (text, name, email, phone, website): == (with an optional trailing wildcard *)

    • Choice fields (dropdown, radio, yes/no, user, state): ==

    • Numeric fields: ==, >, <, >=, <=

    • Date fields: ==, >, <, >=, <= using full ISO 8601 format

    • Multi-select fields: == matches records containing the specified option

If a standard field and a custom field have the same name, the standard field takes precedence.

Please note that filtering on non-indexed custom fields is supported but may result in slower query performance.

For complete details and examples, please refer to the API documentation.

Support for the remaining resources that currently support custom field filtering in XML-RPC will also be added to REST v2 soon.

@OmarAlmonte, well done in your team finally adding this functionality into REST v2.

REST has been around for nearly 10 years and it has taken that long to add the custom field querying functionality into it. The problem is that for several years multiple developers have been asking for this to be added and were given a poor excuse by your predecessors. So they either stuck with XML-RPC, done a workaround solution, abandoned the integration, or have changed platforms.

Customers and Developers need to be informed about this long standing request finally being fulfilled.

This isn’t working for me. I am trying to query for Contacts with certain custom field values.

Here is the custom field definition as returned by https://api.infusionsoft.com/crm/rest/v2/contacts/model:

    {
      "id": "1033",
      "label": "Market",
      "options": [
        {
          "id": "Dallas",
          "label": "Dallas",
          "options": null
        },
      ],
      "record_type": "CONTACT",
      "field_type": "LIST_BOX",
      "default_value": null,
      "group_id": "1",
      "group_name": "Custom Fields",
      "field_name": "Market"
    },

Here is the query I am making:

GET https://api.infusionsoft.com/crm/rest/v2/contacts?filter=Market%3D%3DDallas

And the response:

{
  "code": 400,
  "message": "Field filter does not have a matching enum for value market. Valid values are: EMAIL, CONTACT_IDS, IDS, FAMILY_NAME, GIVEN_NAME, MIDDLE_NAME, COMPANY_ID, START_UPDATE_TIME, END_UPDATE_TIME, PHONE_NUMBER, PHONE_FIELDS, BILLING_ADDRESS_LINE1, BILLING_ADDRESS_LOCALITY, BILLING_ADDRESS_REGION, BILLING_ADDRESS_POSTAL_CODE, BILLING_ADDRESS_COUNTRY_CODE, SHIPPING_ADDRESS_LINE1, SHIPPING_ADDRESS_LOCALITY, SHIPPING_ADDRESS_REGION, SHIPPING_ADDRESS_POSTAL_CODE, SHIPPING_ADDRESS_COUNTRY_CODE, OTHER_ADDRESS_LINE1, OTHER_ADDRESS_LOCALITY, OTHER_ADDRESS_REGION, OTHER_ADDRESS_POSTAL_CODE, OTHER_ADDRESS_COUNTRY_CODE, WEBSITE, LEAD_SOURCE_NAME, CONTACT_ID.",
  "status": "Bad Request",
  "details": [
    {
      "domain": "contact",
      "resource": "GET /rest/v2/contacts"
    }
  ]
}

I am seeing the same for querying Orders by custom fields.

@Randy_Baldwin This should be fixed now.