This documentation explain what is and how to use request actions in Advanced REST Client.
Create request actions to dynamically assign variables when the response from the endpoint is ready. ARC gives you convenient editor to create actions that are performed each time the request is send.
Actions can be conditional. Create a condition rule for the request action and the action is performed only if all conditions are meet.
This help page is to describe in details how to use request actions and conditions.
Request actions overview
There are two groups of actions that can be performed during the request
request actions - executed before the connection is made
response actions - executed when response is ready
Currently request action only allows you to set a value on a variable before the request is made. This value is not stored in the data store bur rather in memory only. This means when you restart the application the variable value will be restored to it's original value.
Request action with definition
In this example a myAccessToken variable is set to empty string before the request is executed.
Response actions are more complex as they are made to extract data from the response and assign the value to a variable or store the variable in the data store.
The data can be extracted from each part of the request/response parts of the HTTP message: URL, headers, status line, and the payload.
Extracting the data from the response
You need to tell the application where to look for the data that you want to extract from the response. In the editor you can select either Request or Response as a main data source. In both cases the rest of the configuration is the same but it uses either request or response values.
Next step is to define what type of data the application should query for the value. It can be Url, Status code, Headers or Body.
Except for status code you should also define path to the data. Depending on selected type you can use different paths.
Path to the data
If you not specify path the application will use the whole URL of the last response (it can be more than one response if there was redirection). You can specify following paths for url:
host - Returns the host value, e.g. api.domain.com
protocol - Returns URL's protocol, e.g. https:
path - URL's path, e.g. /path/to/resource.json
query - Returns full query string, e.g. version=1&page=test
query.[any string] - Returns the value of a query parameter. For query.version it would return 1and for query.page the value will be test.
hash - Returns everything that is after the # character, e.g. access_token=token&state=A6RT7W
hast.[any string] - It treats hash as query parameters and returns the value of the parameter. For hash.access_token it would return token
XML path supports attr(ATTRIBUTE NAME) function that returns the value of the attribute:
path = 'people.person.0.name.attr(first)' // george
Defining the resulting action
When path is set you can define two actions to be performed on the data. You can either permanently Store variable in application internal database or Assign variable temporarily until you restart the application. Last item is to define variable name that will be updated with the value.
Response action definition
You can add a condition to the action so the action will be executed if all defined conditions are meet.
To add a condition to the action click on Add condition button. Source, Type and Path to data works the same way as in Action editor.
After you define source of the data then choose operator to be used to compare the data. It can be one of:
Contains can operate on strings, whole headers object (contains "content-type") and on JSON objects (contains "property").
Last field to set up is Condition value which is used to compare the data.