CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • SOLVED: Chaining via Rest - json examples needed for the mortals please.
Pages: [1]

Author Topic: SOLVED: Chaining via Rest - json examples needed for the mortals please.  (Read 1157 times)

SweetTooth

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
SOLVED: Chaining via Rest - json examples needed for the mortals please.
November 15, 2012, 01:14:17 pm
Recently, it's been possible to chain api calls via AJAX/Rest as per http://issues.civicrm.org/jira/browse/CRM-11169

Can someone please give an example of an api call in json syntax, even better still a chained api call.

Also, would anyone know if it's possible to search for contacts by a criteria (for example a custom field matching a value) and then have all the contacts removed from a group? If so, if you could give an example of a search and then a chained remove from group. I would love you very much. Honest! ;-)




« Last Edit: November 15, 2012, 09:27:27 pm by SweetTooth »

SweetTooth

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
Re: Chaining via Rest - json examples needed for the mortals please.
November 15, 2012, 03:14:12 pm
OK. After more (re)searching I've found this thread on the subject:

http://forum.civicrm.org/index.php/topic,26825.0.html

I can now perform the search for a list of contacts back.

However, according to the documentation found here:

http://wiki.civicrm.org/confluence/display/CRMDOC42/Chaining

It looks like chaining is limited to an additional operation on the same contact.

If that's true, what is the viability of a feature request to expand it to chain to operations on more than one record?

EDIT :

I was hoping for example that this:

https://www.mysite.com/civicrm/api/json?{"entity":"Contact","action":"Get","last_name":"smith","api.GroupContact.Create":{"group_id":57}}

Would put everyone with the last name of "Smith" into a group.

But since I couldn't get:

https://www.mysite.com/civicrm/api/json?{"entity":"Contact","action":"Get","id":"1","api.GroupContact.Create":{"group_id":57}}

To put anything into that group, it's doesn't mean that the API can't cater for multiple contacts.

Either I'm doing something wrong (Most likely) or CiviCRM API doesn't chain into adding contacts into groups.

Does anyone have any ideas?
« Last Edit: November 15, 2012, 03:19:54 pm by SweetTooth »

SweetTooth

  • I post occasionally
  • **
  • Posts: 70
  • Karma: 1
  • CiviCRM version: 4.1
  • CMS version: Drupal 6.20
  • MySQL version: 5.1.54
  • PHP version: 5.2.17
Re: Chaining via Rest - json examples needed for the mortals please.
November 15, 2012, 03:30:28 pm

Hurah!!!! Solved!!!  ;D

Should have read the returned data more. I didn't release I had to explicitly say that I wanted ver 3 of the API!

https://www.mysite.com/civicrm/api/json?{"version":3,"entity":"Contact","action":"Get","last_name":"Smith","api.GroupContact.Create":{"group_id":57}}

Does the trick....all the contacts with last name smith were added to the test group.

((( CiviCRM API )))

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • SOLVED: Chaining via Rest - json examples needed for the mortals please.

This forum was archived on 2017-11-26.