Open topic with navigation
AlertSite UXM’s API monitors run API tests created with Ready! API or SoapUI to check your API availability, correctness and response time from multiple locations around the globe. You can monitor both SOAP and REST APIs.
This tutorial explains how to create an API test, configure content assertions for API results, and upload the test to AlertSite UXM for monitoring. We will use the Country web service as an example:
It is a SOAP web service, but the procedure for REST web services is similar.
We will use Ready! API to create and configure the API test project. You can download a trial version of Ready! API here.
Note: If you already know how to create Ready! API test cases with assertions, or if you have an existing API test to use, skip to step 4.
To create tests for a SOAP API, you need a WSDL file. The WSDL file describes API operations, parameters, the returned data structure, and other information about the API.
You can usually access the WSDL file by appending ?WSDL at the end of the web service URL. For example, if the web service URL is:
then the WSDL file is here:
Let’s start by creating a project in Ready! API:
Your project should look like the following image. You can see that the API has two interfaces for different SOAP versions – countrySoap for SOAP 1.1 and countrySoap12 for SOAP 1.2.
Now we need to create a test case that would run API operations and verify their result.
Let’s create a test case for the GetCountryByCountryCode operation. This operation converts a two-letter country code to the country name (for example, FR to France).
To create a test case:
Now we have a test case with one step that calls the GetCountryByCountryCode operation.
Many API operations have parameters. Be sure to specify the parameter values in the corresponding test steps. If parameter values are missing, the API may return errors.
In our example, the GetCountryByCountryCode operation has one parameter – a two-letter country code. Let’s use FR as this parameter’s value:
In the CountryCode text box, enter FR.
API tests should include assertions to check that the API works correctly and returns the correct results. Without assertions, the test checks only the API availability, but not the returned data.
Let’s verify that the GetCountryByCountryCode operation returns the correct results. In our example, it should convert FR to France. We already specified FR as the input parameter, so now let’s create the assertion:
In the response, right-click GetCountryByCountryCodeResult (the innermost item) and select Add Assertion > for Content.
In the dialog that appears, review the Expected Result – it should contain France.
You should see the green circle on the Assertions tab at the bottom of the request editor. This means the assertion has been successfully validated.
Now that you have a working Ready! API test, you can upload it to AlertSite for monitoring.
You can do this:
First, export your Ready! API project to a ZIP file:
In Ready! API, select Project > Export from the main menu.
Then, in AlertSite UXM:
Select API and click Upload and Monitor.
Select your test case, and click Next.
Enter the monitor name and how often it should run, and click Create.
On the screen that follows, click Test on Demand. This will run the test from a remote location to ensure the monitor can work from arbitrary locations.
If the test fails, review the errors and fix your Ready! API test appropriately, then export and upload the project again.
Congratulations! You have just created your first API monitor. It will start collecting data shortly, and you can see the results on the AlertSite dashboards.
Ready! API v. 1.3 and later include the AlertSite Connector plugin. With this plugin, you can create API monitors in AlertSite directly from Ready! API:
Click Monitor APIs on the toolbar. This will open the AlertSite Connector:
Enter your AlertSite email and password, and click Connect.
You will see the Connected to AlertSite message on successful login.
Now you can create an API monitor from your test:
Click Add Monitors in the top left.
You will see the API Status page with your monitor added. The monitor will start running shortly, and you will see its status.
If you need to change the monitor settings (run interval, monitoring locations and others), use the Click here link to open AlertSite, and proceed from there. For details, see Editing a Monitor.
You may want to change the monitor settings in AlertSite to best fit your API monitoring needs:
For a complete list of settings, see SoapUI API Monitor Settings.
AlertSite stores SoapUI test logs to help troubleshoot API test failures. The logs contain full HTTP request and response data, assertion results, and any errors that occurred.
A SoapUI log is attached to email alerts if email recipients have the Attach server response to e-mail alerts option selected. You can also review the logs in AlertSite if the monitor has Capture Level enabled.
To view SoapUI logs in AlertSite, go to Monitors > Runs and select your monitor. Expand a failed run, then click Detail Report.
In the report that opens, click the camera icon.
The next screen lets you access SoapUI logs. View Step Log opens the log of just that step, and View Run Log opens the log of the whole run, including all step logs.
Below is an example of a step log. You can see that the test failed, because the API response did not contain the expected value.