function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CustomDataIntegrationsCustomDataIntegrations 

How do I call the Bulk API from my Controller?

I am developing an application in SalesForce.  At one point, I make a call out to an outside webservice which returns some that I load to a file.  I load this into a Document and save it to the user documents, but there is also some data that is returned that I want to use to update records with.  I have been reading about the Bulk API, but I do not quite understand how I would call this from my controller.  I understand the limits and batches and that in my case, I will have to batch my updates.  

 

How do I go about sending my batches to the Bulk API?  Can someone give me an example or point me to one? 

 

Thanks!

jhurstjhurst

Hello.


There is not really a way for you to call the Bulk API from Apex.  The way to call the Bulk API is to open a thread from an external system into salesforce and submit the data you want processed.

 

There are a couple of potential ways you could approach this:

 

1. If you have control over the webservice that you are calling, you could change it such that instead of returning the data  you are trying to process with the Bulk API, you would  instead have it call the Bulk API itself.  You would essentially be bypassing the Apex part and just making a Bulk API call.  To better understand how you would submit the call from your webservice, please review the documentation around building a client for the Bulk API - http://www.salesforce.com/us/developer/docs/api_asynch/index.htm

 

2. If you do not have control of the webservce, you other option woul dbe to process the records in a different way.  If you are interested in taking advantage of the asynchronouus nature of the Bulk API, then you could probably take advantage of Batch Apex.  The idea would be to process the data that you want to use to update your resords, and then submit that data to the batch interface to be processed.  You can learn more about Batch Apex at http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_batch.htm?SearchType=Stem

 

Hope this helps.

Jay