You need to sign in to do that
Don't have an account?
Diwakar G 7
System.LimitException: Too many callouts: 101 in API Call
Hi,
I am trying to call api using executeAPI method. The response is jobid. Now, I am checking whether the job is completed or not using checkStatus method continuously in while loop. It will take around 5 min to complete the job.
Thanks and Regards,
Diwakar G
I am trying to call api using executeAPI method. The response is jobid. Now, I am checking whether the job is completed or not using checkStatus method continuously in while loop. It will take around 5 min to complete the job.
Public class PageController{ public static String getMethod(String instance_url,String token){ Http http = new Http(); HttpRequest req = new HttpRequest(); req.setEndpoint(instance_url); req.setMethod('GET'); req.setHeader('Authorization', 'Bearer '+token); HTTPResponse res = http.send(req); String json1 = res.getBody(); return json1; } public static void executeAPI(String token){ String instance_url = 'https://api'; String json1 = getMethod(instance_url, token); return json1; } public static void checkStatus(String jobid,String token){ String instance_url = 'https://api/job/status/'+jobid; String json1 = getMethod(instance_url, token); Map<String, Object> data1 = (Map<String, Object>) JSON.deserializeUntyped(json1); while(data1.get('isFinished') == False) { json1 = getMethod(instance_url, token); data1 = (Map<String, Object>) JSON.deserializeUntyped(json1); } System.debug('Success'); } public static void mainFunction(){ token = 'avdndbdn' String json1 = executeAPI(token) Map<String, Object> data1 = (Map<String, Object>) JSON.deserializeUntyped(json1); checkStatus(data1.get('JobId'),token) } }But, I am getting "System.LimitException: Too many callouts: 101 in API Call" error. Please help me.
Thanks and Regards,
Diwakar G
Raj Vakati
Is its complete code ? from where you are calling this method ?
Diwakar G 7
I am calling these methods inside mainFunction method. From developer console, in execute anonymous window, I am executing mainFunction method.