Answers.Body: <p>Try adding: <code>option.limit=0</code> to you request?</p>
  
  <p>ex:</p>
  
  <p><a href="https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX&amp;json=" rel="nofollow noreferrer">https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX&amp;json=</a>{"sequential":1,"id":1,"options":{"limit":0}}</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-11T15:35:35.440Z
Answers.LastActivityDate: 2016-11-11T15:35:35.440Z
Answers.UserDisplayName: bgm
Answers.Body: <p>I just created a working example for <code>curl</code> and tested it on linux. Do also URL encode the curly braces. I used the <a href="http://meyerweb.com/eric/tools/dencoder/" rel="nofollow noreferrer">this website</a> to do that. So <code>{"contact_id":"358383"}</code> becomes <code>%7B%22contact_id%22%3A%22358383%22%7D</code> .</p>
  
  <p>I used curl with different parameters. My example is</p>
  
  <pre><code>curl -X POST "http://localhost/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX&amp;json=%7B%22sequential%22%3A%221%22%2C%22id%22%3A%222%22%7D"
  </code></pre>
  
  <p>Update: I see I am a bit misleaded by the example generated by the api explorer. JSON for parameters is not mandatory. It is possible to use the following format.</p>
  
  <pre><code> curl -X POST "http://localhost/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX&amp;json=1&amp;contact_id=2"
  </code></pre>
  
  <p>See <a href="https://civicrm.stackexchange.com/questions/4974/rest-api-without-json-just-key-value">REST API without JSON just key=value</a> .</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-11T16:40:49.003Z
Answers.Text: Excited to try this now! And yes! This works: curl -X POST "https://mysite.ca/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json=1&contact_id=358383"
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-11T16:45:09.837Z
Answers.Text: I just added a closing " at the end of your second curl example
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-11T16:47:58.637Z
Answers.Text: And you're %7B%22contact_id%22%3A%22358383%22%7D works too! :-) Thank you!
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-11-11T15:38:39.520Z
Answers.LastActivityDate: 2016-11-11T16:44:24.867Z
Answers.LastEditDate: 2017-04-13T12:53:13.167Z
Answers.UserDisplayName: Kainuk - CiviCooP
Body: <p>Ok - it's my first time diving into REST API - First of all trying to get it to return me just the data for one specific contact. It works great in the browser but on the command line no matter what I try I keep getting the data for the first 25 contact_ids in the civicrm_contact table; it's simply ignoring my very specific attempts to just give me contact_id: 358383;</p>
  
  <p>I've tried [and they all return data for the first 25 contact_ids in either json or xml - that all works fine]:</p>
  
  <p>CiviCRM 4.6 LTS - and Drupal 7.x</p>
  
  <pre><code>curl -i -H "Content-Type: application/json" -X POST -d '{"contact_id":"358383"}' "https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX"
  
  curl -i -H "Content-Type: application/json" -X POST "https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX&amp;json={"contact_id":"358383"}"
  </code></pre>
  
  <p>or  </p>
  
  <pre><code>curl -i -H "Content-Type: application/json" -X POST "https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&amp;action=get&amp;api_key=XXX&amp;key=XXX&amp;json={contact_id:358383}"
  </code></pre>
  
  <p>If anyone has any examples/suggestions that would be great! I'm curl-ing on MacOSX - from what I've been reading "/%22' syntax could be important.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-11-13T01:52:10.410Z
Comments.Text: Really worth looking into what the encoding means, and how it's interacting with both your commandline environment and the webserver. I'd aim to reduce extra "noise" if you can (`{contact_id:1}` works as well as `{"contact_id":"1"}`), and to understand what encoding you require (putting a `"` inside the quotes at the beginning and end of the URL will cut the rest of your URL off, which I suspect why you found encoding `"` to `%22` helped, but maybe wrapping the URL in a pair of `'` would have been simpler?).
Comments.UserDisplayName: Chris Burgess
Tags: <api>
Title: How to use the REST API with curl
ThreadText: # How to use the REST API with curl
  
  (Asked by: username_0 on 2016-11-11)
  
  Ok - it's my first time diving into REST API - First of all trying to get it to return me just the data for one specific contact. It works great in the browser but on the command line no matter what I try I keep getting the data for the first 25 contact\_ids in the civicrm\_contact table; it's simply ignoring my very specific attempts to just give me contact\_id: 358383;
  
  I've tried [and they all return data for the first 25 contact\_ids in either json or xml - that all works fine]:
  
  CiviCRM 4.6 LTS - and Drupal 7.x
  
  ```
  curl -i -H "Content-Type: application/json" -X POST -d '{"contact_id":"358383"}' "https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX"
  
  curl -i -H "Content-Type: application/json" -X POST "https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json={"contact_id":"358383"}"
  
  ```
  
  or
  
  ```
  curl -i -H "Content-Type: application/json" -X POST "https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json={contact_id:358383}"
  
  ```
  
  If anyone has any examples/suggestions that would be great! I'm curl-ing on MacOSX - from what I've been reading "/%22' syntax could be important.
  
  **Tags:** api
  
  > **Comments:**
  > **username_1**: Really worth looking into what the encoding means, and how it's interacting with both your commandline environment and the webserver. I'd aim to reduce extra "noise" if you can (`{contact_id:1}` works as well as `{"contact_id":"1"}`), and to understand what encoding you require (putting a `"` inside the quotes at the beginning and end of the URL will cut the rest of your URL off, which I suspect why you found encoding `"` to `%22` helped, but maybe wrapping the URL in a pair of `'` would have been simpler?).  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2016-11-11. Score: 4 | Accepted answer
  
  I just created a working example for `curl` and tested it on linux. Do also URL encode the curly braces. I used the [this website](http://meyerweb.com/eric/tools/dencoder/) to do that. So `{"contact_id":"358383"}` becomes `%7B%22contact_id%22%3A%22358383%22%7D` .
  
  I used curl with different parameters. My example is
  
  ```
  curl -X POST "http://localhost/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json=%7B%22sequential%22%3A%221%22%2C%22id%22%3A%222%22%7D"
  
  ```
  
  Update: I see I am a bit misleaded by the example generated by the api explorer. JSON for parameters is not mandatory. It is possible to use the following format.
  
  ```
   curl -X POST "http://localhost/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json=1&contact_id=2"
  
  ```
  
  See [REST API without JSON just key=value](https://civicrm.stackexchange.com/questions/4974/rest-api-without-json-just-key-value) .
  
  > **Comments:**
  > **username_0**: Excited to try this now! And yes! This works: curl -X POST "https://mysite.ca/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json=1&contact_id=358383"  
  > **username_0**: I just added a closing " at the end of your second curl example  
  > **username_0**: And you're %7B%22contact_id%22%3A%22358383%22%7D works too! :-) Thank you!  
  
  ---
  
  ### Answer by username_2 on 2016-11-11. Score: 1
  
  Try adding: `option.limit=0` to you request?
  
  ex:
  
  <https://example.org/sites/all/modules/civicrm/extern/rest.php?entity=Contact&action=get&api_key=XXX&key=XXX&json=>{"sequential":1,"id":1,"options":{"limit":0}}
  
  
  ---
  
  