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}' );
req.setMethod('GET');
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;
}
}
something like what they posted? But isn't invocable already a future callout?
– User_11223344 Jul 07 '21 at 19:23