Groups and Environments
Environments and Groups assist in keeping track of varying parameters and values unique to your API across multiple deployments and other contexts. Within the Environments section of Requests, you can create Groups. Groups are used to store Environments; within Environments you can store key-value pair variables.
An example of how you may use these functions is if you have two deployments of your API, Production and Staging. You want to send requests to these deployments from multiple user roles such as Developer, Admin, and Unauthenticated User. In this case, you would have a group called Deployment with two environments: Production and Staging, and a second group called User with three environments: Developer, Admin, and Unauthenticated User. When you send a request to one of your API's endpoints, you can select which deployment and user you want to use (e.g. Production and Developer). All relevant variables for those environments will be sent in your request, for example, your production's RequestURL and your Developer's authToken.
Creating a Group
Before you can create an environment, you need to create a group. To create a group, locate the Environments panel within Requests and select the + icon to the right of Groups.
Whenever a new group is created, a new environment will automatically get created for that group. You can rename both the group and environment by selecting the three vertical dots to the right and selecting Rename. After typing in the new name, clicking off the name field will auto-save the new name.
Creating an Environment
There are two ways to create an environment: by adding a new environment or by duplicating an environment.
Add environment
To add a new environment, select the three vertical dots to the right of the group where you want to add the environment and select Add environment.
Duplicate environment
To duplicate an environment, select the three vertical dots to the right of the environment you want to duplicate and select Duplicate.
Adding a Variable in an Environment
To add a variable to an environment, enter the variable's name in the Add Variable Name field. Note that encapsulating this name in double curly brackets (e.g. {{variableName}}), or triple curly brackets when a special character is used (e.g. {{{variable.Name}}}), is how you will reference the variable in your request.
If there is a static value you want to set the variable to, you can type it in the Add Value field to the right of the associated variable name.
For more advanced values, you can right click in the Add Value field; this will present a menu of other values you can add.
A new variable row will appear automatically, so you do not need to click a button to add a new variable.
Deleting a Variable
You can delete a variable by selecting the three vertical dots to the right of the variable and selecting Delete.
Updated about 1 year ago