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:
https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&api_key=userkey&entity=Contact&sequential=1&json=1&action=get&first_name=Heidi
That works as expected using the exact match on Heidi
. I tried using the LIKE
operator using array syntax:
https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&api_key=userkey&entity=Contact&sequential=1&json=1&action=get&first_name[like]=Heidi
I get the expected response, but this uses the exact value and no wildcard characters.
I've tried three different options for wildcards:
- Like array no wildcard:
https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&api_key=userkey&entity=Contact&sequential=1&json=1&action=get&first_name[like]=Heid
- Like array with wildcard:
https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&api_key=userkey&entity=Contact&sequential=1&json=1&action=get&first_name[like]=Heid%
- Like array with encoded wildcard:
https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&api_key=userkey&entity=Contact&sequential=1&json=1&action=get&first_name[like]=Heid%25
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.