I am trying to do a simple GET request using a LIKE operator with a wildcard. It's easy to set up the explorer and works as expected. I'm using a demo civi environment using the example data included on install. There are two Heidis in the database.

The rest URL generated in the explorer is:
https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php ?entity=Contact &action=get&api_key=userkey&key=sitekey&json={"sequential":1,"first_name":{"LIKE":"Heid%"}}

As is, I know that the URL will generate the error: Unable to decode supplied JSON.

I have reformatted it to:

That works as expected using the exact match on Heidi. I tried using the LIKE operator using array syntax:

I get the expected response, but this uses the exact value and no wildcard characters.

I've tried three different options for wildcards:

  1. Like array no wildcard:
  2. Like array with wildcard:
  3. Like array with encoded wildcard:

None of the three wildcard attempts produce an error, but they return 0 results. I've looked through the docs and have done multiple Google searches but I can't find a workable solution. Any help would be greatly appreciated.

1 Answer 1


the correct syntax is the one at the top:

"first_name": {"LIKE":"hei%"}

to work around the encoding issues (that might be tricky indeed), don't try to put all the params in the url (as http get) but use a http post (the api works with both)

  • Each of the top three works, it's really just the wildcard character that I'm struggling with.
    – DaveBagler
    Commented Apr 12, 2021 at 18:17
  • use http post instead of get, solves the dealing with escaping of % and json
    – Xavier
    Commented Apr 12, 2021 at 19:05
  • Yeah, I'll have to do it as a multipart/form-data POST.
    – DaveBagler
    Commented May 20, 2021 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.