Chaining Requests

Let's say you want to use data returned from an API call to make another call to a second API. This chaining can help us create complex tests that validate the full functionality of the API and not just individual endpoints.

Every API request has a "Variable" setting. This defines the name of the variable that the response will be saved into. You can use this variable in subsequent test steps to use data from the API & make assertions on the response.

To chain requests, add your first HTTP request step, fill in any necessary parameters, and set the name of the variable that the response will be saved into. In the example below, the result of the first API call is saved as "apiResponse". To use data from this request in a second request, you can add it as a variable call.

This syntax can go anywhere β€” in the URL, in a header value, param value, or the request body. In this example, we got a list of products from the MyStore API and are referencing the id of the first product in that list.

In the image below, the result of the second API call will be saved into the variable "firstProduct".

1093

You can see how we built the syntax for the second request by referencing the execution report and inspecting the values in the first request. See the Data Fetch page for more details.

792