Collection Values
RestApia allows you to define variables, headers, and cookies at the workspace and folder levels, streamlining your request configurations and reducing repetition. These collection values can be overridden at the request level, providing granular control.
Hierarchy and Precedence
RestApia follows a clear hierarchy for resolving collection values:
- Workspace Level: Values defined at the workspace level provide a baseline configuration.
- Folder Level: Values defined within a folder override workspace-level values. Folders can be nested, with values in deeper folders taking precedence.
- Request Level: Values defined directly within a request override both workspace and folder-level values.
This hierarchical system allows for flexible and organized management of your request settings.
User Values vs. Environment Values
RestApia offers two distinct types of collection values: User Values and Environment Values.
User Values
- User Values are independent of environments and can be enabled or disabled as needed.
- You can enable multiple User Value sets simultaneously, allowing for flexible configurations (e.g., “Global Settings,” “Private Values”).
- If the same variable, header, or cookie is defined in multiple enabled User Value sets, the last defined value takes precedence.
- User values can be defined with Providers:
- Regular User Values: Saved within your request collection files.
- Private Values: Encrypted and stored locally on your machine, ensuring sensitive data is not shared. The encryption key is derived from your machine identifier, making the data unreadable on other systems.
- Azure KeyVault: (Requires RestApia extension) Allows you to retrieve secrets from Azure KeyVault as variables. You’ll need an Azure account and to configure the connection within RestApia.
- … and more will come with Extensions.
Environment Values
- Environment Values allow you to switch between different configurations (e.g., “Development,” “Staging,” “Production”).
- Only one environment can be active at a time.
- Environment Values override all User Values.
- User can use environment and some user values at same time.
Managing Collection Values
Collection Values are managed through a dedicated editor, similar to the request editor.
- Context Menu: User Values and Environments can be accessed and created through the context menu in the requests collection list.
- Request Editor Panel: On the top right of the request editor, there is a panel that shows the effective variables for the request.
- Clicking on an environment will switch to that environment.
- Clicking on User Values allows you to enable or disable them (like checkboxes).
User Values example
// variables
variable 1: value 1
variable 2: value 2
// headers
@custom-header1: value 1
@custom-header2: value 2
// cookies
$myCookie1: value 1
$myCookie2: value 2