Answers.Body: <p>the correct syntax is the one at the top:</p>
  <p>&quot;first_name&quot;: {&quot;LIKE&quot;:&quot;hei%&quot;}</p>
  <p>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)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-12T18:17:09.443Z
Answers.Text: Each of the top three works, it's really just the wildcard character that I'm struggling with.
Answers.UserDisplayName: DaveBagler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-12T19:05:52.667Z
Answers.Text: use http post instead of get, solves the dealing with escaping of % and json
Answers.UserDisplayName: Xavier
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-20T13:58:59.567Z
Answers.Text: Yeah, I'll have to do it as a multipart/form-data POST.
Answers.UserDisplayName: DaveBagler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-11T15:45:19.777Z
Answers.LastActivityDate: 2021-04-11T15:45:19.777Z
Answers.UserDisplayName: Xavier
Body: <p>I am trying to do a simple <code>GET</code> request using a <code>LIKE</code> 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.</p>
  <p>The rest URL generated in the explorer is:<br />
  <code>https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php ?entity=Contact &amp;action=get&amp;api_key=userkey&amp;key=sitekey&amp;json={&quot;sequential&quot;:1,&quot;first_name&quot;:{&quot;LIKE&quot;:&quot;Heid%&quot;}}</code></p>
  <p>As is, I know that the URL will generate the error: <code>Unable to decode supplied JSON.</code></p>
  <p>I have reformatted it to:<br />
  <code>https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&amp;api_key=userkey&amp;entity=Contact&amp;sequential=1&amp;json=1&amp;action=get&amp;first_name=Heidi</code></p>
  <p>That works as expected using the exact match on <code>Heidi</code>. I tried using the <code>LIKE</code> operator using array syntax:<br />
  <code>https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&amp;api_key=userkey&amp;entity=Contact&amp;sequential=1&amp;json=1&amp;action=get&amp;first_name[like]=Heidi</code></p>
  <p>I get the expected response, but this uses the exact value and no wildcard characters.</p>
  <p>I've tried three different options for wildcards:</p>
  <ol>
  <li>Like array no wildcard:<br />
  <code>https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&amp;api_key=userkey&amp;entity=Contact&amp;sequential=1&amp;json=1&amp;action=get&amp;first_name[like]=Heid</code></li>
  <li>Like array with wildcard:<br />
  <code>https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&amp;api_key=userkey&amp;entity=Contact&amp;sequential=1&amp;json=1&amp;action=get&amp;first_name[like]=Heid%</code></li>
  <li>Like array with encoded wildcard:<br />
  <code>https://civi.site.com/wp-content/plugins/civicrm/civicrm/extern/rest.php?key=sitekey&amp;api_key=userkey&amp;entity=Contact&amp;sequential=1&amp;json=1&amp;action=get&amp;first_name[like]=Heid%25</code></li>
  </ol>
  <p>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.</p>
  
Tags: <api><rest>
Title: Using the LIKE operator with a wildcard using API v3's REST interface
ThreadText: # Using the LIKE operator with a wildcard using API v3's REST interface
  
  (Asked by: username_0 on 2021-04-09)
  
  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:
  
  1. 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`
  2. 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%`
  3. 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.
  
  **Tags:** api, rest
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-04-11. Score: 3 | Accepted answer
  
  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)
  
  > **Comments:**
  > **username_0**: Each of the top three works, it's really just the wildcard character that I'm struggling with.  
  > **username_1**: use http post instead of get, solves the dealing with escaping of % and json  
  > **username_0**: Yeah, I'll have to do it as a multipart/form-data POST.  
  
  ---
  
  