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

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>';
            //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){

    global void finish(Database.BatchableContext BC){


 Called by:

    public static void scheduleQueuedBatchJobs(){
       g2wGetRegistrantDetailsBatch job=new g2wGetRegistrantDetailsBatch();
       String query='Select Id, CampaignId FROM CampaignMember';
       Id getRegistrantDetailsBatchJobId = Database.executeBatch(job, 1);//need the batch size at 1 due to callout limit of 1 per batch


Best Answer chosen by Admin (Salesforce Developers) 

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?

This was selected as the best answer

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.