I am attempting to schedule a flow that runs every night and passes the dates of the previous two days into these variables, then calls the apex class to run. The variables are based on the time when this flow runs.

Right now, i'm trying to make sure the callout functions before moving on the to the rest.

In my class, I am making a call out to the endpoint URL (from the flow) to the URL in my apex class. However, with the attached code, I am getting the error: An Apex error occurred: System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out

public with sharing class responseTap {

@invocableMethod(label='Response Tap' description='Request sent to Response Tap to get GCLID\'s for Line 1 Calls' category='Callout')

public static void rTap(List<String> strInput) {

    Date todayDate = Date.today()-1;
    Date otherDate = Date.today()-2;

    HttpRequest req = new HttpRequest();
    req.setEndpoint( 'callout:rTapUrl/accounts/5120/enhancedCallRecords&startDate=' + todayDate + '&endDate=' + otherDate + '&format=json');
    req.setHeader('Authorization', 'Basic ' + '{!$Credential.Password}' );
    Http http = new Http();
    HTTPResponse res = http.send(req);

    List<rTapRequest> parsedResponse =  (List<rTapRequest>) JSON.deserialize(res.getBody(), List<rTapRequest>.class);

    System.debug('What does this look like? >>> '+ parsedResponse);

public class rTapRequest {

    public String scrollId;
    public List<EnhancedCallRecords> enhancedCallRecords;

public class EnhancedCallRecords {
        public String cdrId;
        public Integer dailyCallId;
        public String disposition;
        public Integer duration;
        public Integer talkTime;
        public String callerId;
        public String callerNumber;
        public String callerCountry;
        public String callerLocation;
        public String callerLineType;
        public String visitorId;
        public String visitId;
        public String trackingId;
        public String trackingName;
        public String trackingNumber;
        public String destinationNumber;
        public String source;
        public String medium;
        public String channel;
        public String campaign;
        public String referrer;
        public String landingPage;
        public String conversionPage;
        public String googleAdsCampaign;
        public String googleAdsAdGroup;
        public String googleAdsKeyword;
        public String googleAdsMatchType;
        public String gclid;
  • To make sure i'm understanding, I would have to invoke the first method to grab the input dates, then convert those to a string. Callout that string then add it as my input for my method that's sending the request? something like what they posted? But isn't invocable already a future callout? Jul 7, 2021 at 19:23
  • AFter some testing, that does not answer my question. Jul 7, 2021 at 20:16
  • 1
    could you update your post, explaining your "tests" as well as why the dupe does not answer your question. Thanks
    – glls
    Jul 7, 2021 at 20:42
  • Invocables are synchronous with the flow or Process Builder transaction. Invocables can delegate work to async though. You should show your Flow as well, use Edit
    – cropredy
    Jul 8, 2021 at 5:27
  • I have updated the original code as I think what is showing now should be more condensed. I have removed the variables from the flow process and let the date get created in my apex class. However, I am still getting this error. The flow is a scheduled flow, with the time at 12am daily. After that it calls this apex class and that is it. Should I not be doing this through a scheduled flow? Jul 8, 2021 at 13:53

1 Answer 1


Please add a Pause step before the step that invokes the Apex class. The pause can be for just a moment. This will ensure that a new transaction begins before you invoke the callout and resolve this issue.

  • I have one scheduler apex, one flow, and one apex to make integration, the scheduler calls the flow, and the flow calls the apex of integration, in this case, should give an error of "Callout from scheduled Apex not supported"? Sep 21, 2022 at 18:40

Not the answer you're looking for? Browse other questions tagged .