Skip to main content

Error Handling API Workflow

Call an API with TryCatch error handling and email notification on failure

Steps

#ActivityWhat it does
1TryCatchWrap API call in error handler
2HttpRequestCall the API (inside try block)
3WriteLineLog success (inside try block)
4WriteLineLog error (inside catch block)
5SMTPEmailSend error notification (inside catch block)

Workflow

try:
apiResponse = HttpRequest("https://api.example.com/data", "GET")
WriteLine(apiResponse)
except Exception as errorMessage:
WriteLine(errorMessage)
SMTPEmail("ops@example.com", emailBody=errorMessage, emailSubject="API Error Alert")