I'm trying to download all of the ActivityHistories from our SFDC account. I would like to use the Bulk API to avoid hitting the API rate limit for the day. I'm using the following query to do so:

SELECT (SELECT ActivityDate, Description, WhatId, Subject, Status, Priority,
        WhoId, Location, IsClosed, DurationInMinutes, ActivityType, AccountId,
        IsAllDayEvent, IsTask FROM ActivityHistories) FROM Opportunity

However, the results returned are empty. Am querying incorrectly, or is this not supported via the Bulk API? If not, what's the best way to download a copy of all of the activities for opportunities ~twice daily?


There is no issue with your Query or Rest API. When i tried to run it in workbench it just worked fine.

I will suggest you to check :

1) you have data in your org 2) your code properly iterating over the response

To check your query you can do fllowing

1) Go to https://workbench.developerforce.com and do authentication
2) Go to Utilities -> Rest explorer menu
3) Enter get url as /services/data/v29.0/query?q=SELECT+id,+(SELECT+ActivityDate,+Description,+WhatId,+Subject,+Status,+Priority,+WhoId,+Location,+IsClosed,+DurationInMinutes,+ActivityType,+AccountId,+IsAllDayEvent,+IsTask+FROM+ActivityHistories)+FROM+Opportunity 4) Click Execute
5) It wills how you output data

| improve this answer | |
  • That doesn't use the bulk api does it ? – Samuel De Rycke May 30 '14 at 7:16
  • No i dont think it use bulk api. But my point was when you can pull result from Query rest api why it would not allow to retrieve same data with bulk API? – AtulRajguru9 May 30 '14 at 7:23

You're going to have a couple problems using the Bulk Api for this type of query. First, the bulk API does not support querying on deleted or archived records. It has no equivalent to the SOAP APIs 'queryAll()' method. If you're running this job every day, this may not be an issue . But if you're trying to retrieve tasks older than 12 months, the bulk api won't work for you.

Second, the bulk api has many restrictions on the types of queries you can perform. According to the documentation, you cannot have nested SOQL queries in your query. You're query from above has a nested query. You could potentially get around this by querying for all Activities where ParentId like '006%', but that would be really inefficient since it couldn't use the indexes.

SOAP or REST APIs seem like your best bets.


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.