In Apidog, a variable serves as a dynamic placeholder for values that can be utilized across multiple API requests and scripts. When executing a request or script, Apidog references the current value of the variable.By grouping variables into environments, you can easily adapt your testing setup to different work scenarios (e.g., Development, Testing, Production).
Here's a quick guide to creating and using variables in Apidog.
1
Open the PetStore ProjectOpen the default PetStore project, which is pre-installed in your Team space for every user.
2
Open Environment ManagementLocate and click the environment icon β‘ at the top right in your interface.
3
Create a VariableFind the Global Variables section. Create a new variable called my_variable with "123" as its initial value.
4
Save ChangesClick the Save button.
5
Use in an EndpointOpen the "Find pet by ID" endpoint, and switch to the Run tab.
6
Insert VariableLocate the path parameter "PetId", and add {{my_variable}} as the value.
7
View ValueMove your cursor over the variable name to view its current value and scope.
8
Switch EnvironmentClick the Environments dropdown besides the β‘ icon, and switch to the Local Mock environment.
9
Send RequestClick Send to execute the request.
10
Verify ReplacementYou will find the response displayed in the lower half of the interface. By switching to the Actual Request tab, you can view the request that was actually sent, with variables replaced by their respective actual values.
For a deeper understanding of variables in Apidog, see Using Variables.
The term "environment" is commonly used in development teams to distinguish between "development," "testing," "production," and so on. Each environment encompasses one or a set of servers.
When the client is in a particular environment, all requests are sent to the servers in that environment.
Upon switching environments, requests are directed to a different set of servers.