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.
{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?).