I have created a schedule class with AllowCallouts interface used and invoking my batch Apex from It and also my Batch Apex has allowcallouts interface used. But still i am getting CalloutException. i am doing a callout in start method of batch apex and execution methods from re usable BAL helper class
Scheduler
global class KanbanizeCardActivitySchedule implements Schedulable, Database.AllowsCallouts {
global void execute(SchedulableContext sc) {
//small code blocks of getting
//username,pswd,others from custom setting
//Inovoke of batch apex
if(string.isNotBlank(userName) && string.isNotBlank(paswd) ){
ID jobID = database.executeBatch(new KanabanizeCardActivityBatch(fieldsSet, wherClause, userName, paswd ), 200);
system.debug('--jobID for Kanabanize Data Check--'+jobID);
}
}
Batch Apex
global class KanabanizeCardActivityBatch implements Database.Batchable<sobject>, Database.AllowsCallouts {
global KanabanizeCardActivityBatch(set<String> qFields, String whClause, string kanbanUserName, string kanbanPswd){
KanabanizeService_BAL.doLoginKanbanize(kanbanUserName, kanbanPswd);
if(KanabanizeService_BAL.isStatusOkForLogin()){
//setting some final variables here, based on response
}
}
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(queryString);
}
global void execute(Database.BatchableContext BC, List<sObject> scope){
//making a callout in execute method, some heavy lines cant share here
}
global void finish(){}
however when i call my batch apex outside scheduler pulling everything perfectly. Not sure this behaviour even after using allowcallouts interface. As per sf documentation we can call batch apex with allow callouts implemented.