HowTo manage error handling in HTTP requests
In this article, you'll learn how to catch errors when occurred in HTTP request events.
After reading this article you will know:
-
How to get the error information
-
How to setup basic error handling
Error info as
When creating an HTTP request you'll notice that you can set the Error info as variable. This variable collects error information about the request, which can then be used for the remainder of the action.
The variable is treated as an Object, where 2 attributes can be accessed, containing the information. The 2 attributes are:
-
success: Was the request successful? Returns
true
orfalse
. -
message: The (error) message the webservice returned.
The data is stored in JSON:
In case the request is successful, this variable will be blank
, as no error turned up.
For the remainder of this article, we'll refer to this variable as var:error_info
.
Getting the error information
As explained above, the information is stored as JSON data in the variable. To access the attributes and their values, you'll need 2 additional variables.
Success
To access the value in the success attribute, create a Checkbox expression variable.
Call the variable success, and enter the following expression.
You can use this variable in Conditions or other events to check if the request was successful.
Message
To access the value in the message attribute, create a Text expression variable.
Call the variable message, and enter the following expression.
You can use this variable in Conditions events to check what kind of error you received and in Create/Update events to save the error in a Text property!
Setting up error handling
When the request has failed, the success variable we just created will return false. You can use this in a condition to setup a different action for when an error occurs. In the example below, we send an email to a developer about whether or not the request completed succesfully.
