Retry and Error Mechanism for Rest outbound integration
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
03-03-2024 02:40 AM - edited 03-03-2024 03:57 AM
Hi Folks,
I am currently implementing a REST Outbound integrations to send the CI information to Workspace Third party tool.
It is a uni-directional integration and no other major stuff.
FYI: using schedule job and script include so no flows involved here for error handling.
I would appreciate if someone could share the retry mechanism and error handling issues to be included in the script
try {
     r.setRequestBody();
    var response = r.execute();
    if (response) {
        var responseBody = response.getBody();
        var httpStatus = response.getStatusCode();
        gs.log('Asset ID: ' + gr.getValue('sys_id') + ', Response: ' + responseBody + httpStatus);
    } else {
        //ERROR Handling mechanism
        gs.log('Error: The response from the REST call was null or undefined.');
    }
} catch (e) {
    gs.log('REST call failed with error: ' + e.toString());
}@Community Alums @AndersBGS @Ankur Bawiskar @Amit Gujarathi @Maik Skoddow
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
03-03-2024 03:56 AM
Hi @Resham Noor
1. Do you have a set of common error that you get ? If yes store them in servicenow to associate a retry/error mechanism using scheduled jobs.
2. You can create a workflow with all common errors which triggers the retry or fix mechanism. This will again run condition or scheduled bases.
3. If the errors received as minimal , lets say 2 or 3 you can simply feed them in rest call itself to retry based on getStatusCode();
I hope this helps...
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
 - Bookmark
 - Subscribe
 - Mute
 - Subscribe to RSS Feed
 - Permalink
 - Report Inappropriate Content
 
03-03-2024 09:07 PM
you need to have custom logic for this
you can have max 3 retry count and loop it and wait for 2-3mins for every loop
example: start with count as 1 and hit the API, check the response if it fails wait for 2-3mins and then again run the loop, increment the count as 2 and do same
stop the loop when count reaches 3
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
