You need to sign in to do that
Don't have an account?

Batch Job Error: FATAL_ERROR System.LimitException: Too many callouts: 1
Really confused here - batch jobs are allowed 1 callout execute(), and I made 1, and then got this error.
I set the batch size to 1 as well.
In fact, I basically copy & pasted a different batch job where I'm doing something very similar, with the only change here being I'm using the standard "implements Database.Batchable<sObjects> " instead of a custom iterable. Any thoughts?
global with sharing class g2wGetRegistrantDetailsBatch implements Database.Batchable<sObject> { public String sObjectQuery ='Select Id, CampaignId FROM CampaignMember' ; global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator(sObjectQuery); } global void execute(Database.BatchableContext BC, List<sObject> scope){ //Process this 1 campaignMember. The batch size is always 1 due to 1 callout / batch job limit CampaignMember cm=(CampaignMember)scope[0]; Campaign campaign=[SELECT Id FROM Campaign WHERE id=:cm.campaignId LIMIT 1]; String requestURL='<my API request URL>'; try{ //Get registrant details system.debug('The request URL is'+requestURL); HttpResponse response=g2wUtils.getResponse(requestURL);//send out the request to the other server }catch(DMLException e){ }//try }//execute global void finish(Database.BatchableContext BC){ }//finish }//g2wGetRegistrantDetailsBatch
Called by:
public static void scheduleQueuedBatchJobs(){ g2wGetRegistrantDetailsBatch job=new g2wGetRegistrantDetailsBatch(); String query='Select Id, CampaignId FROM CampaignMember'; job.sObjectQuery=query; Id getRegistrantDetailsBatchJobId = Database.executeBatch(job, 1);//need the batch size at 1 due to callout limit of 1 per batch }//scheduleQueuedBatchJobs
You don't have Database.allowsCallouts in this batch. Is your other batch doing callouts too?
All Answers
Try to create a method in another class and add @future(Callout=true)
Hope that works..
You don't have Database.allowsCallouts in this batch. Is your other batch doing callouts too?
Thanks! That was it!
I did not have Database.AllowsCallouts in this batch class but did in the other.
I didn't see it as I'm using a vertical monitor for Eclipse and it was off the screen for both.