Usecase:
Enhancing the API's resilience by introducing error handling to fall back to a backup service if the primary REST API for retrieving country details fails. Additionally, global fault handling will be implemented to deliver a custom fault response for consistent error messaging.
Primary service:
https://restcountries.com/v3.1/alpha/IND
Backup service:
https://api.worldbank.org/v2/country/IND?format=json
Logic steps:
- Create 2 Rest invoke connections for primary and backup services.
- Create a application integration and configure the trigger with
- Uri: /country/{code}
- Get operation
- Provide json response
- Configure Primary service Rest api
- Take a scope and keep the primary service inboke and map inside of it.
- Add scope fault handler and do the following
- Configure backup service
- Map the input code
- Take a return action and map the details.
- Configure global fault
- Add "throw new fault" action to send custom fault to OIC Error Hospital
Trigger response:
{
"name": "United States of America",
"alpha2Code": "US",
"alpha3Code": "USA",
"capital": "Washington
}
Detailed screenshots:
No comments:
Post a Comment