How to check the api call successful or failed from 3rd party ?

jaiho_rai
Kilo Sage

Hi Team ,

 

How do I check if the API call from a 3rd party is successful or failed ?

How should I update the worknote only once? The next call should not update the worknote in inc ?

1 ACCEPTED SOLUTION

Maddysunil
Kilo Sage

@jaiho_rai 

you can use below code to check API call fail/pass

 

// Make API call to third-party system
var response = thirdPartyApiCall();

// Check if the API call was successful
if (response && response.getStatusCode() === 200) {
    // API call was successful
    var responseBody = response.getBody(); // You can inspect the response body for further details
    gs.info("API call successful. Response: " + responseBody);

    // Update incident or take further actions based on the response
} else {
    // API call failed
    gs.error("API call failed. Status code: " + response.getStatusCode());

    // Handle error scenario or log error details
}

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

View solution in original post

9 REPLIES 9

Danish Bhairag2
Tera Sage

Hi @jaiho_rai ,

 

Are you using scripted Rest Api?

 

Thanks,

Danish

yes , but thing need to achieve , but some them configured via import set as well.

 

Whenever it call for the first time only that time will it will update the work note in the incident or if it failed, 

after that need to send notification(email ) to concern team 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @jaiho_rai 

 

How do I check if the API call from a 3rd party is successful or failed ?

Atul: Its code, like 200 is considered as success code. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

@Dr Atul G- LNG 

That I understood but specifically it should work only for the first-time call, they have multiple things scripted apis and import set.