How is your experience with the OutSystems Community?
28
Views
2
Comments
Solved
Api failure message in exception handling
Question

Hi All,

I wanted to handle the api failure and retry for 2 times in LIB laye and collect  the failure message as an email,

I have checked as per earlier forum reply in allexceptions to call the api again with retry count but the recursive approach does not work in allexceptions,

Is there any common menthodoligy acrross the application to handle in lib layer .

Currently  set the flag false in allexception and calling method to handle for each api currently.

2026-05-21 04-48-12
Deepa Tiwari
Solution

Hi @Preeti zade ,

As @Siya  mentioned, there isn't a generic built-in approach for this. We implemented a similar retry mechanism in one of our applications, and the following pattern worked well:

  1. Create a RetryQueue entity to persist failed API requests. Include fields such as:
    • Id
    • RecordId
    • RetryCount
    • RequestJson
    • ResponseJson
    • IsSuccess
    • ErrorMessage
    • CreatedOn
    • LastRetryOn
  2. Centralize all external API integrations in a Library.
    • Expose a Server Action for each API.
    • Handle exceptions within the Library.
    • Return a standardized response structure, for example:

      Response- RecordId- Success (Boolean)- ErrorMessage

  3. Consume the Library actions from your application.
    • If Response.Success = True, continue with the normal flow.
    • If False, insert a record into the RetryQueue with the request payload and relevant error details.
  4. Create a Timer that periodically processes failed requests.
    • Fetch records where:
      • IsSuccess = False
      • RetryCount < MaxRetryCount
    • Re-execute the corresponding API call using the stored request data.
    • If successful:
      • Update IsSuccess = True
      • Store the response (if required).
    • Otherwise:
      • Increment RetryCount
      • Update the error/response details.
  5. Configure the Timer schedule based on your retry strategy (e.g., every 30  minutes).

This approach provides a reusable, centralized retry framework, avoids duplicate retry logic across modules, and gives you complete visibility into failed integrations for monitoring and troubleshooting.

Hope this will help you.
Regards
Deepa

2019-01-07 16-04-16
Siya
 
MVP

I don't think there's a generic way to do this. Since each consumed REST API is its own action, the retry logic usually has to be implemented by the caller or in a wrapper specific to that API.

2026-05-21 04-48-12
Deepa Tiwari
Solution

Hi @Preeti zade ,

As @Siya  mentioned, there isn't a generic built-in approach for this. We implemented a similar retry mechanism in one of our applications, and the following pattern worked well:

  1. Create a RetryQueue entity to persist failed API requests. Include fields such as:
    • Id
    • RecordId
    • RetryCount
    • RequestJson
    • ResponseJson
    • IsSuccess
    • ErrorMessage
    • CreatedOn
    • LastRetryOn
  2. Centralize all external API integrations in a Library.
    • Expose a Server Action for each API.
    • Handle exceptions within the Library.
    • Return a standardized response structure, for example:

      Response- RecordId- Success (Boolean)- ErrorMessage

  3. Consume the Library actions from your application.
    • If Response.Success = True, continue with the normal flow.
    • If False, insert a record into the RetryQueue with the request payload and relevant error details.
  4. Create a Timer that periodically processes failed requests.
    • Fetch records where:
      • IsSuccess = False
      • RetryCount < MaxRetryCount
    • Re-execute the corresponding API call using the stored request data.
    • If successful:
      • Update IsSuccess = True
      • Store the response (if required).
    • Otherwise:
      • Increment RetryCount
      • Update the error/response details.
  5. Configure the Timer schedule based on your retry strategy (e.g., every 30  minutes).

This approach provides a reusable, centralized retry framework, avoids duplicate retry logic across modules, and gives you complete visibility into failed integrations for monitoring and troubleshooting.

Hope this will help you.
Regards
Deepa

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.