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) »
  • api.activity.get returns huge amounts of data for bulk email activities
Pages: [1]

Author Topic: api.activity.get returns huge amounts of data for bulk email activities  (Read 416 times)

ktate

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.6.16
  • PHP version: 5.5.3
api.activity.get returns huge amounts of data for bulk email activities
October 01, 2014, 07:22:27 am
I'm using the REST API to pull down all the activities for a contact:

http://path_to_civi/civicrm/extern/rest.php?entity=Activity&action=get&contact_id=1300&rowCount=100&json=1

One of the fields returned in the JSON is "targets" which includes all targets for that activity. This is fine for most activities but for bulk emails it ends up causing the request to fail (someone has 300 bulk emails which each email going to 100,000 contacts and suddenly 30 million key:values need to be returned). Is there anyway to suppress the target field in the call?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: api.activity.get returns huge amounts of data for bulk email activities
October 01, 2014, 07:25:53 am
The return param allows you to specify the fields you want returned. If you leave it out then you get the defaults.
So you could add e.g.
Code: [Select]
&return=subject,activity_type_id,activity_date_time to your query.
« Last Edit: October 01, 2014, 07:27:49 am by Coleman Watts »
Try asking your question on the new CiviCRM help site.

ktate

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.6.16
  • PHP version: 5.5.3
Re: api.activity.get returns huge amounts of data for bulk email activities
October 01, 2014, 08:09:59 am
Thanks!

Yes I had already tried that, unfortunately it doesn't seem to work. I notice that with return there are still some fields that are returned no matter what. Targets seems to be one of them?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: api.activity.get returns huge amounts of data for bulk email activities
October 01, 2014, 12:54:59 pm
Activity.get has some legacy behaviour if you pass in contact_id - I think it looks for the contact being any of the possible related types. If you don't pass in contact_id then it will do the things you expect. I would be prepared to fix this up now because I think we could query the activity_contact table (& also accept a type) and solve more than one problem. But that would be in the 4.4 LTS / ? maybe a 4.5 release but maybe not til 4.6 at the earliest so it may not help you if I do
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

ktate

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 6
  • MySQL version: 5.6.16
  • PHP version: 5.5.3
Re: api.activity.get returns huge amounts of data for bulk email activities
October 05, 2014, 02:04:13 pm
Yes looking at the code for api.activity.get, it switches on the case where the params includes contact_id. If this is the case it pulls activities where the contact is either the source, the target or the assignee. This is actually probably the desired behaviour, the issue is more that CiviMail creates one activity per mailing and targets the entire list it was sent to.

In the app I'm building I have just sidestepped the API for this entity get until it is fixed.

Thanks for the responses!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • api.activity.get returns huge amounts of data for bulk email activities

This forum was archived on 2017-11-26.