In previous blog posts, I described how API Science monitors could be used to create global variables and retrieve and verify them. In this post, we’ll create a new monitor that deletes an API Science global variable, then study what effect this has on the earlier monitors.
My “Set Dog and Meal” monitor sets the following variables (creating them if they don’t already exist):
- my_dog: Fido
- my_meal: steak
- my_status: hungry
My “Dog and Meal Status” monitor retrieves the variables, and uses an API Science Regex validation to verify that the text “my_meal” was returned as part of the response body.
To demonstrate deleting variables, I create a new monitor:
Here I’ve configured a monitor named “Fido Eats” that accesses the API Science variables API (
https://api.apiscience.com/v1/variables) using the HTTP
DELETE; the monitor runs every hour from Washington, DC.
Clicking the “Show Settings” link lets me enter the required authentication credentials and configure additional details:
Authentication HTTP header provides the API with my API Science API key. The
DELETE method will be applied (
Saving and running the monitor produces this result:
The HTTP status code 200 indicates that the API call was processed successfully. The response body lists the current set of global variables for my API Science account, which lets me verify that a global variable named “my_meal” no longer exists.
But now, when I go to my “Dog and Meal Status” monitor, I see the following:
The monitor says the API is down. Scrolling down to “Recent Checks” I see:
The response code is 200, indicating that the actual call to the API succeeded (the API processed the request and returned a response). The status of the call is “Failure” because a specified validation requirement was not passed.
Clicking on the date and time link brings us to the details for the failed API check:
The call failed because the Regex validation for this monitor found that the response body does not include the required text “my_meal”; this is the case because the “Fido Eats” monitor deleted that variable from my account.
My “Dog and Meal Status” monitor won’t remain down forever, though. The next time my “Set Dog and Meal” monitor runs, the “my_meal” variable will be recreated (and reset to “steak”), and all three monitors will report statuses of “Success” — until the next time Fido eats and I come looking for my steak…
The three monitors created in this series of posts illustrate how API Science global variables can be used to coordinate multiple monitors. The variables provide a means for communicating information between monitors, facilitating more complex verification of the status of the APIs that are critical for your product.