I need to build an apex class that will perform multiple callouts in a row to an external system and upsert some records.
Right now I'm sending a POST method with a query in the body and getting an amount of data greater than the heap size limit (12mb)
@future(callout=true)
public static void runBigQuerySql(){
String jsonResponse;
String sql = 'SELECT * FROM <table>';
GoogleBigQuery google = new GoogleBigQuery();
google.runQuery(sql);
jsonResponse = google.getResponse();
JsonResponse response = (JsonResponse) System.JSON.deserialize(jsonResponse,
JsonResponse.class);
List<Account> listAcct = new List<Account>();
listAcct.add(
new Account(
FirstName = item.f.get(0).v,
LastName = item.f.get(1).v,
Phone = item.f.get(2).v
.....
)
.....
}
How can I workaround the heap size in this scenario? I thought about using the LIMIT and OFFSET statements to get small lots of data and make multiple callouts to get all records. But I'm not sure how to refresh the heap size limit for each callout.