You need to sign in to do that
Don't have an account?
vignesh balasubramanian 14
How to make Http callouts in batch class
Hi Everyone,
Could anyone explain me that how to make Http callouts in batch class with example.
Note:Need to call the batch class from apex trigger
Could anyone explain me that how to make Http callouts in batch class with example.
Note:Need to call the batch class from apex trigger
BatchSync BS = new BatchSync();
Database.executeBatch(BS,10); // you can also do less than 10
You can also take help from these link
1-https://developer.salesforce.com/forums/?id=906F0000000kK6VIAU
2-http://www.forcedisturbances.com/2012/03/caching-data-from-googles-geocoding.html
I Hope you will choose my answer as best answer
All Answers
To use HTTP Callouts in batch class we need to use Database.allowcallouts in interface.
More info check below links :
http://www.cloudforce4u.com/2013/11/call-batch-apex-from-trigger.html
https://salesforce.stackexchange.com/questions/19444/batch-apex-with-webservice-callout (http://www.cloudforce4u.com/2013/11/call-batch-apex-from-trigger.html)
Hope this helps.
please let me know if you need any further information.
Thanks
Varaprasad
I tried but it shows " System.AsyncException: Database.executeBatch cannot be called from a batch start, batch execute, or future method " error.
Kindly give me solution to fix it.
Thanks,
Vignesh.b
you are calling callouts batch class in Trigger right?
Please use @future(callout = true) to execute method and checkonce.
Thanks
Varaprasad
Step 1: Create Apex Class
First step is to create an apex class. After you login, click on Setup > Develop > Apex Classes > New.
Step 2: Write future method
Write future method that calls external service.
Step 3: Add external server to Remote Sites
Click Setup > Security Controls > Remote Site Settings > New Add external site name and endpoint URL
Site:cheenath endpoint url:http://cheenath.com/
Step 4: Create APEX trigger
Click Setup > Customize > Accounts > Triggers > New
And create the following trigger:
Yes, it works well, but not for bulk records thats why I'm asking you the way to achieve this using batch class.
BatchSync BS = new BatchSync();
Database.executeBatch(BS,10); // you can also do less than 10
You can also take help from these link
1-https://developer.salesforce.com/forums/?id=906F0000000kK6VIAU
2-http://www.forcedisturbances.com/2012/03/caching-data-from-googles-geocoding.html
I Hope you will choose my answer as best answer
Please check below post for sample code
1) https://salesforce.stackexchange.com/questions/19444/batch-apex-with-webservice-callout
Hi All,
I need some inputs how to integrate salsforce with gOogle adwors API . I have specific CRM campaign information id which is matching with awords campaign and needs to update the data.
How to achieve this.