Scripting
Variables

Vars tab

Vars tab allows you to set variables:

  • before request and
  • after you receive the response.

Variables are scoped within the request and cannot be accessed outside of it.

Note: Prior to v1.20.0, request vars were accessible at the collection scope, but this is no longer the case.

In the Vars tab > Pre Request variables section, you can write any strings, numbers or any valid JavaScript literal.

In the Vars tab > Post Response variables section, you can write any valid JavaScript expression. The res object is available, allowing you to declaratively parse the response object and set variables, instead of writing scripts to do the same.

For parsing the response, you can checkout the response query that allows you to easily query your response.

Example: bru vars

Screenshot showing how to use defined variables in the request body