Test the execution status of an API endpoint periodically using the Try Catch block. Let us walk through this document, understand the requirements, and the steps to configure a test journey for your API endpoint.
What you'll need:
Skill level: Intermediate
Time required: 5 minutes
- Scheduler by Quickwork as a trigger--for triggering the journey
- An API endpoint and its associated API key
- Business Logic:
- Try Catch
- If Else
- Actions:
- HTTP
- Logger
- Slack
Configuring the trigger
- In the Event section, choose the Scheduler by Quickwork app from the drop-down menu in the Apps field present right below the New Trigger button.
- Select the trigger event as New scheduled event from the drop-down menu in the Triggers field.
- Set the Interval as per your choice based on how often you want the document to be merged. Let us select 15 seconds.
- Set the date and time of your choice in the Start At field and keep the Custom Payload field empty.
- No authorization is required as this is an app created by Quickwork:
Using the Try Catch block
Let us use the Try Catch block to check whether the API endpoint is executing perfectly or not. We must specify an API endpoint in an action under the Try block. Then place the Error data pill under the Catch block such that any exemptions occurring are handled effectively.
Configuring the HTTP action under Try block
- In the Steps section, click on the Business Logic button and choose Try Catch.
- Click the Step 2 action bar. Select HTTP from the App drop-down menu.
- Select Send new request as an action.
- Enter the name of the API in the Request name field. E.g., User Login API.
- Select application/json as Request content type.
- Select POST as the Request HTTP method.
- Enter the API endpoint in the Request URL field. E.g., https://apim.quickwork.co/hargrid/logon_creds/1/apim.
- Now, scroll down to the Request headers object.
- Enter apiKey as a name in the Header name field.
- Specify the actual API key in the Header Value field:
Configuring the Logger action under Catch block
- Click the Step 4 action bar. Select Logger from the App drop-down menu.
- Select Log a Message as an action.
- Drag and drop the Error data pill from the Catch action under Data Tree Output:
Introducing the If Else condition
The purpose of using the If Else Condition and the actions within is to validate and send the notifications to a user as per the functioning of the API endpoint, respectively.
Configuring the If Condition
- Click the + icon, click the Business Logic option, and select If Else Condition.
- The If Else Condition block will appear with the pre-indented action bars.
- In the Left Value field, drag and drop the Status Code data pill from the HTTP | Send new request response under Data Tree Output.
- Select the Equals condition from the drop-down menu in the Condition field.
In the Right Value field, enter 200. The status code 200 means the API endpoint is working perfectly:
Configuring the Slack action under If Condition
- Click on the Please choose an action bar under the If block.
- Choose the Slack app from the drop-down menu in the App field.
- Select the action, Send message to a channel, from the drop-down menu in the Action field.
- Click the Link account button to connect Slack with Quickwork.
- In the Channel toggle field, choose the Select from list operation and then select the channel name in which you want the message to appear. E.g., mypersonal.
- Enter the message in the Message field to be displayed on your Slack channel. E.g., The User Login API is working fine.
- Leave all the other input fields empty:

Configuring the Slack action under Else Condition
- Click on the Please choose an action bar under the Else block, Step 8.
- Choose the Slack app from the drop-down menu in the App field.
- Select the action, Send message to a channel, from the drop-down menu in the Action field.
- In the Channel toggle field, choose the Select from list operation and then select the channel name in which you want the message to appear. E.g., mypersonal.
- Enter the message in the Message field to be displayed on your Slack channel. E.g.,
The User Login API is malfunctioned. It might have stopped functioning due to following three reasons:
1. Incorrect API endpoint.
2. Incorrect API key.
3. Bad gateway. - Leave all the other input fields as empty:
Executing the journey
The Try Catch journey is now successfully configured. It must look like this:
Save the changes of the journey and click Save & Start. Now go to your Slack channel. You'll see that after every 15 seconds, the status message of the API endpoint pops up:
In case of an invalid API endpoint or API key, the exception is handled by the Catch block resulting in a seamless flow of the journey. As a result, the following error message is obtained in the channel:
Comments
0 comments
Please sign in to leave a comment.