Answers.Body: <p>In the end, I was only able to make it work by using array notation. Some examples below. All these worked in the array notation on the right, but not in the object notation on the left:<br/><br/>
  <b>"options": {"limit":"100","offset":"100"}</b>&nbsp;&nbsp;--->&nbsp;&nbsp;<b>"options[limit]": "1","options[offset]": "100"</b><br/><br/><b>"custom_1": {"IS NOT NULL":"1"}</b>&nbsp;&nbsp;--->&nbsp;&nbsp;<b>"custom_1[IS NOT NULL]": "1"</b><br/><br/><b>"custom_1": {"LIKE": "%stringtosearch%}</b>&nbsp;&nbsp;--->&nbsp;&nbsp;<b>"custom_1[LIKE]":"%stringtosearch%"</b><br/><br/>So in my case my json payload looked like this:</p>
  
  <pre><code>json = {
        "return": "id,custom_116,custom_16",
        "custom_16[IS NOT NULL]": "1",
        "custom_15[&lt;&gt;]": "",
        "options[limit]": "50",
        "options[offset]": "50",
        "options[sort]": "id"
      }
  </code></pre>
  
  <p>Next task is to work out how to convert the OR option into array notation:<br/><br/>"options":{"or":[["custom_15","custom_16"]]}&nbsp;&nbsp;---> ???</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-27T15:06:33.507Z
Answers.LastActivityDate: 2019-12-04T13:22:37.660Z
Answers.LastEditDate: 2019-12-04T13:22:37.660Z
Answers.UserDisplayName: Jern
Answers.Body: <p>I, too, had problems getting the json parameter to work when using the REST URL generated by API Explorer. I kept receiving the following error:</p>
  <pre><code>{
  &quot;is_error&quot;: 1,
  &quot;0&quot;: &quot;error_message&quot;,
  &quot;1&quot;: &quot;Unable to decode supplied JSON.&quot;
  }
  </code></pre>
  <p>The response about using array syntax didn't work as written, but it did put me on the right track. Here is what I ended up with:</p>
  <p><a href="https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=apikey&amp;key=sitekey&amp;sequential=1&amp;json=1&amp;last_name%5BLIKE%5D=%Wag%&amp;options%5Blimit%5D=100" rel="nofollow noreferrer">https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=apikey&amp;key=sitekey&amp;sequential=1&amp;json=1&amp;last_name[LIKE]=%Wag%&amp;options[limit]=100</a></p>
  <p>The array syntax isn't inside the json parameter; rather it's part of its own querystring parameter.</p>
  <p>Doing this also worked:</p>
  <p><a href="https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=apikey&amp;key=sitekey&amp;sequential=1&amp;json=1&amp;last_name=Wagner&amp;limit=100" rel="nofollow noreferrer">https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=apikey&amp;key=sitekey&amp;sequential=1&amp;json=1&amp;last_name=Wagner&amp;limit=100</a></p>
  <p>However, array syntax was the only way I could get the comparison to work with something other than equality.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-04-09T15:29:14.597Z
Answers.Text: I wasn't able to get the wildcards working in the like call, are the wildcards still working for you?
Answers.UserDisplayName: DaveBagler
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-11-17T21:01:10.333Z
Answers.Text: Huge Help to getting the LIKE condition to work with the REST API v3
Answers.UserDisplayName: CTG
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-22T22:34:28.867Z
Answers.LastActivityDate: 2020-09-22T22:34:28.867Z
Answers.UserDisplayName: Cory Wagner
Body: <p>I have the CiviCRM API REST interface working fine for retrieving Case information for individual cases. But I'd like to use the options features options.limit and options.offset so I can retrieve data page by page from CiviCRM in response to a search. But whatever I try, nothing seems to alter the limit and the offset numbers of the retrieved records. Only the first 25 records are returned, ie the default number. Has anyone else had a similar problem?</p>
  
  <p>The json payload looks like this:</p>
  
  <pre><code>json={
  "return":"id,custom_116,custom_16",
  "custom_116":{"IS NOT NULL":1},
  "options":{"limit":100,"offset":100}
  }
  </code></pre>
  
  <p>This is the REST format suggested by the API explorer (v3). </p>
  
  <p>Am I doing something wrong? The search criterion ("IS NOT NULL") is ignored as above, but searches works correctly when not in object format, eg "custom_116":"StringToSearch". The limit and offset parameters are also ignored. So it seems likely that the problem is to do with the object format for these parameters. Any ideas? Or is there an alternative way of formatting the query json? Thanks.</p>
  
  <p>CiviCRM 5.9.0
  Joomla 3.9.1
  php 7.0.31</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-13T22:48:43.843Z
Comments.Text: Regarding IS NOT NULL, the field could also technically be the empty string, so not null would be true. Testing on the public demo seems to confirm this.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-13T23:42:14.790Z
Comments.Text: The limit parameter seems to work for me on a local 5.9.0 install in the object format you have above / as suggested by the api explorer, e.g. `http://path/to/rest.php?entity=Case&action=get&api_key=my_api_key&key=my_site_key&json={"sequential":1,"return":"id,custom_1","custom_1":{"IS NOT NULL":1},"options":{"limit":1}}`  Also the IS NOT NULL comment above seems to hold on my local install - if I use `"<>":""` instead then it works to exclude blank ones. My install is drupal - I doubt that would make a difference for this though.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-01-27T14:12:16.503Z
Comments.Text: Thanks. This doesn't work for me, but I found an answer, posted separately.
Comments.UserDisplayName: Jern
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-29T19:53:06.853Z
Comments.Text: This ^^ was the answer for me regarding civicrm apiv3 get contacts limit. This is why I wish people would quit documenting so heavily in proprietary languages like php that do weird stuff to your payload. If you're writing docs for an http api and if you're going to write it in multiple languages anyway, please for the love of god make one of them the HTTP payload. I'm using Talend. Thank you Jern.
Comments.UserDisplayName: Jason Miller
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-11-30T20:15:05.943Z
Comments.Text: The API Explorer is the primary documentation (**Support menu > Developer > API Explorer**) and generates REST examples for anything you throw at it.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-01T09:46:26.183Z
Comments.Text: The REST example generated by the API Explorer uses the object notation, which doesn't (or didn't) work. Hence the reason for my earlier post.
Comments.UserDisplayName: Jern
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-12-02T04:19:23.850Z
Comments.Text: This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://civicrm.stackexchange.com/questions/ask). You can also [add a bounty](https://civicrm.stackexchange.com/help/privileges/set-bounties) to draw more attention to this question once you have enough [reputation](https://civicrm.stackexchange.com/help/whats-reputation). - [From Review](/review/low-quality-posts/10426)
Comments.UserDisplayName: Luke Stewart
Tags: <api><civicase><rest>
Title: Is there a problem with the REST interface on CiviCRM API?
ThreadText: # Is there a problem with the REST interface on CiviCRM API?
  
  (Asked by: username_0 on 2019-01-13)
  
  I have the CiviCRM API REST interface working fine for retrieving Case information for individual cases. But I'd like to use the options features options.limit and options.offset so I can retrieve data page by page from CiviCRM in response to a search. But whatever I try, nothing seems to alter the limit and the offset numbers of the retrieved records. Only the first 25 records are returned, ie the default number. Has anyone else had a similar problem?
  
  The json payload looks like this:
  
  ```
  json={
  "return":"id,custom_116,custom_16",
  "custom_116":{"IS NOT NULL":1},
  "options":{"limit":100,"offset":100}
  }
  
  ```
  
  This is the REST format suggested by the API explorer (v3).
  
  Am I doing something wrong? The search criterion ("IS NOT NULL") is ignored as above, but searches works correctly when not in object format, eg "custom\_116":"StringToSearch". The limit and offset parameters are also ignored. So it seems likely that the problem is to do with the object format for these parameters. Any ideas? Or is there an alternative way of formatting the query json? Thanks.
  
  CiviCRM 5.9.0
  Joomla 3.9.1
  php 7.0.31
  
  **Tags:** api, civicase, rest
  
  > **Comments:**
  > **username_1**: Regarding IS NOT NULL, the field could also technically be the empty string, so not null would be true. Testing on the public demo seems to confirm this.  
  > **username_1**: The limit parameter seems to work for me on a local 5.9.0 install in the object format you have above / as suggested by the api explorer, e.g. `http://path/to/rest.php?entity=Case&action=get&api_key=my_api_key&key=my_site_key&json={"sequential":1,"return":"id,custom_1","custom_1":{"IS NOT NULL":1},"options":{"limit":1}}`  Also the IS NOT NULL comment above seems to hold on my local install - if I use `"<>":""` instead then it works to exclude blank ones. My install is drupal - I doubt that would make a difference for this though.  
  > **username_0**: Thanks. This doesn't work for me, but I found an answer, posted separately.  
  > **username_2**: This ^^ was the answer for me regarding civicrm apiv3 get contacts limit. This is why I wish people would quit documenting so heavily in proprietary languages like php that do weird stuff to your payload. If you're writing docs for an http api and if you're going to write it in multiple languages anyway, please for the love of god make one of them the HTTP payload. I'm using Talend. Thank you username_0.  
  > **username_3**: The API Explorer is the primary documentation (**Support menu > Developer > API Explorer**) and generates REST examples for anything you throw at it.  
  > **username_0**: The REST example generated by the API Explorer uses the object notation, which doesn't (or didn't) work. Hence the reason for my earlier post.  
  > **username_4**: This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://civicrm.stackexchange.com/questions/ask). You can also [add a bounty](https://civicrm.stackexchange.com/help/privileges/set-bounties) to draw more attention to this question once you have enough [reputation](https://civicrm.stackexchange.com/help/whats-reputation). - [From Review](/review/low-quality-posts/10426)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2019-01-27. Score: 2 | Accepted answer
  
  In the end, I was only able to make it work by using array notation. Some examples below. All these worked in the array notation on the right, but not in the object notation on the left:  
    
  **"options": {"limit":"100","offset":"100"}**  --->  **"options[limit]": "1","options[offset]": "100"**  
    
  **"custom\_1": {"IS NOT NULL":"1"}**  --->  **"custom\_1[IS NOT NULL]": "1"**  
    
  **"custom\_1": {"LIKE": "%stringtosearch%}**  --->  **"custom\_1[LIKE]":"%stringtosearch%"**  
    
  So in my case my json payload looked like this:
  
  ```
  json = {
        "return": "id,custom_116,custom_16",
        "custom_16[IS NOT NULL]": "1",
        "custom_15[<>]": "",
        "options[limit]": "50",
        "options[offset]": "50",
        "options[sort]": "id"
      }
  
  ```
  
  Next task is to work out how to convert the OR option into array notation:  
    
  "options":{"or":[["custom\_15","custom\_16"]]}  ---> ???
  
  
  ---
  
  ### Answer by username_5 on 2020-09-22. Score: 2
  
  I, too, had problems getting the json parameter to work when using the REST URL generated by API Explorer. I kept receiving the following error:
  
  ```
  {
  "is_error": 1,
  "0": "error_message",
  "1": "Unable to decode supplied JSON."
  }
  
  ```
  
  The response about using array syntax didn't work as written, but it did put me on the right track. Here is what I ended up with:
  
  [https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&api\_key=apikey&key=sitekey&sequential=1&json=1&last\_name[LIKE]=%Wag%&options[limit]=100](https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&api_key=apikey&key=sitekey&sequential=1&json=1&last_name%5BLIKE%5D=%Wag%&options%5Blimit%5D=100)
  
  The array syntax isn't inside the json parameter; rather it's part of its own querystring parameter.
  
  Doing this also worked:
  
  <https://mysite.org/wp-content/plugins/civicrm/civicrm/extern/rest.php?entity=Contact&action=get&api_key=apikey&key=sitekey&sequential=1&json=1&last_name=username_5&limit=100>
  
  However, array syntax was the only way I could get the comparison to work with something other than equality.
  
  > **Comments:**
  > **username_6**: I wasn't able to get the wildcards working in the like call, are the wildcards still working for you?  
  > **username_7**: Huge Help to getting the LIKE condition to work with the REST API v3  
  
  ---
  
  