Store API Variables
Overview
In scriptless automation, storing values from API responses allows subsequent API calls to utilize these stored values for further operations or validations. This document explains how to configure the storage of response values and how to utilize them in subsequent API calls.
Storing Values from API Responses
Configuration
The CSV template for an API call includes a RESPONSE:STORE_VALUE
parameter that determines whether to store a specific value from the API response. The configuration is as follows:
RESPONSE:STORE_VALUE: Set to a variable name to store the corresponding value from the given JSON path in the response. Set to
NONE
to skip storage.
Example
For an API call that creates a new entry (e.g., using POST
), the template might look like this:
In this example, the value from 'Column 1'
in the response is stored in a variable named Name
.
Utilising Stored Values in Subsequent Calls
Usage Template
Stored values can be utilized in subsequent API calls by referencing them in the template. The reference is made using a specific syntax, often prefixed with an identifier like ApiGlobalVariables
.
Example
For a subsequent API call that retrieves data (e.g., using GET
), the template might reference the stored variable as follows:
In this example, the template references ApiGlobalVariables:Name
, which utilizes the value stored in the variable Name
from the previous API response.
Use of Stored Values
In addition to the RESPONSE:EXPECTED_VALUE
, stored values can be utilized in various other parts of the API call template. Stored values can be used in the following components:
END_POINT: Incorporate stored variables into the endpoint URL to dynamically change API endpoints based on previous responses.
PARAMS:VALUE: Use stored variables as parameter values in the API request.
AUTH:VALUE: Apply stored variables in authentication fields, useful for dynamic authentication scenarios.
HEADERS:VALUE: Include stored variables in request headers, such as dynamically generated tokens or session data.
BODY:VALUE: Insert stored variables in the request body, allowing the body content to change based on previous responses.
Conclusion
Storing and utilising values from API responses is a powerful feature in scriptless automation, enabling dynamic data handling and interdependent API testing. By configuring the RESPONSE:STORE_VALUE
appropriately and referencing stored values using a designated syntax, testers can create flexible and efficient automated API tests. This approach is particularly useful in scenarios where the output of one API call is a prerequisite for subsequent calls.
Last updated
Was this helpful?