Failure Conditions

While using APIs/GraphQL/DB connectors, initially you configure the API/GraphQL/DB connector and then use Add API/Add Query to configure. Once configured, the response is checked accordingly.

There might be scenarios where you want to handle the failure conditions while designing your apps. Studio enables you to accomplish this by defining the Failure conditions. In the Failure conditions you have to provide the Failure Message and Failure /Error Code. The condition field accepts the inline js code within {{}} and the Failure/Error code is the alphanumeric code which accepts all caps and doesn’t accept special characters except_.It is used for denoting error conditions which can be displayed in your action flow.

While using the ADD API/ADD query category you can view the Response and Failure tabs. In the Failure condition section provide the details and test the result.


For the specified REST API connector you can use the added API or ADD API for the new one.

Select > Connectors >Select API > ADD API

Provide the Connector Name and Failure Conditions.

Below we have defined two failure conditions:

{{ STATUS CODE = 404}} . 404 is the Error code. If it matches then it displays an error message as Internal Error- {{STATUSMESSAGE}}

{{OUTPUT.Envelope.Body.NumberToDollarsResponse.NumberToDollarsResult==‘one dollar’}}. Here if the condition is true it displays the message as provided. In our example “One dollar does not valid”. {{STATUS CODE}}

We have checked true and false failure condition.

Add Query to GraphQL Connector

In graphQL first configure the connector. Click Add API . Provide the inputs and check the response.

Depending on the requirement, provide the failure condition and test the results.

Add Query to DB connector

In the DB connector first configure the connector. Click Add API . Provide the inputs and check the response.

Failure condition in Apps

To implement the failure condition in apps, design your app according to the requirement.

Let us for example convert the given amount in words.

Provide the inputs and bind the connector in the result control. Defalut values are provided in the input text.

If the code is incorrect then internal error is displayed.

The second condition is that if the input is one dollar then it displays the error that the number is not valid.

View the result.

Using Failure Conditions in Action Flow

Failure conditions can also be implemented in action flow. Select the API configured in server side actions and provide the inputs.

Here output 1 and output 2 are the variables assigned to Failure_CODE and Failure_MESSAGE respectively. The output response is assigned as the result variables. The purpose of assigning variables is to make it available for other actions.

Provide the inputs for alert to display error and setctrl_value.
For alert:

For setctrl_value

View the result.

You can view the message and the code assigned to variables output 1 and output 2 respectively.

Hence, failure conditions can be implemented for REST APIs/GraphQL/DB connectors.