Overview
API Hub for Test is a powerful platform designed to streamline and simplify API testing. Built for efficiency and flexibility, it empowers teams to design, execute, and manage API tests with ease. Whether you're testing API endpoints for functionality, performance, or reliability, API Hub provides the tools you need to ensure seamless integrations and robust application performance.
With API Hub for Test, you can confidently validate your APIs, ensuring they perform as expected and meet the highest standards of quality and security.
Define an API request
To add an API call to your test, click the Add an API Call button.
After you click this button, a new section will be displayed that provides options for declaring an API request and validating its response:
Use dynamic values
Dynamic values can be inserted anywhere within the request URL. The request body can be extracted from the response body. To reference a dynamic value, the value must first be assigned to a Variable in an earlier test step or in an Execution Override passed at the outset of the test.
There are two ways to assign a dynamic value:
To replace text: Highlight the text you want to replace and select the option. In the context menu, click the Variable containing the dynamic value you wish to insert.
To insert text: Click the text field and move the text cursor to the location where the dynamic value should be inserted. In the toolbar that appears, click the option and click the Variable containing the dynamic value you want to insert.
Test an API request
After you populate the necessary fields for the API request, you can generate an API response by clicking the Validate Response section.
button on the top right of the screen. This will generate an API request using the values you’ve specified and will populate the response in theAfter you save and execute the test, the app will issue that same API call and validate its response against the criteria you have specified. If one or more validations fail, or if the API response times out, the test step will be marked as failed, and information about the failure (including the API response that was received, if any) will be included in the test run details.
Verify an API response
After generating an API response using the Execute Request button or viewing a completed test run, you can extract specific values from the response in the Validate Response section.
To extract a value, click on the relevant field in the response. A menu will appear, allowing you to:
assign the property value to a variable
create an assertion to validate the property value.
The selected property will be highlighted, and an editable "selector" will be generated. The selector is a UI-driven feature that simplifies identifying elements in the response.
JSON responses
Consider the example API response below:
{ "totalCount": 2, "users": [ { "name": "John Doe", "role": "Guest", "isActive": false }, { "name": "Jane Doe", "role": "Admin", "isActive": true } ] }
XML responses
Along with JSON responses, API Hub for Test also supports validating API calls in XML format. Similarly, values in an XML response can be extracted by clicking on the relevant attribute or element value. After you select the extraction or assertion rule, the attribute or element value will be highlighted, and an editable XPath 1.0 selector will be generated.
Note
Verifying values within an API response that does not return XML or JSON, such as a plain text response, is not supported.
Common use cases
Call APIs to generate test data
In many cases, end-to-end tests depend on pre-existing data within the system-under-test.
For example, to automate testing of a “Delete” action within your web app, you’ll first need to ensure that an entity that can be deleted already exists. These types of destructive test cases are often hard to automate since the application's state changes after every test run and must somehow be reset.
One use of the API Testing feature is to issue API calls to set up test data for a larger end-to-end test. When testing a destructive action like in the example above, we could issue an API call at the beginning of the test, which creates a new entity and extracts a unique identifier for that entity from the API response. We can then record the steps to search for that entity in the UI using the identifier extracted from the API response and finally delete the entity using the UI.
Verify results through API calls
For modern web apps, the system state is often stored across various systems. If you’re using a microservice architecture, the state will be stored across a set of services and exposed through APIs.
In addition, third-party integrations such as Stripe for billing or Auth0 for user identity information often act as their own systems of record.
The API testing feature lets you check if updates were correctly applied to connected systems (both internal and external) by sending API requests and reviewing the responses.
For example, when testing an end-to-end test that adds a payment method, you can end the test by making API calls to Stripe’s API to validate that a relevant Customer and PaymentMethod object has been created.