Parametrizing Rest API calls.
Rivery’s Action Rivers allow you to parametrize calls to Rest API’s and dynamically change the data that is returned/posted. In this guide, we will walk you through how to build in variables into your Action Rivers so that you can take advantage of this powerful functionality.
Create a New Action River
- First, we’ll create a new Action River.
-
In the Action Steps tab, choose the Rest Action option.
-
Configure the URL of your request along with any authentication and headers. For now, don’t fill in any fields that you wish to be defined as parameters:
Creating the Parameters
- Select the button on the right side of the console and enter a name. If you want to hardcode the value of the variable, enter a value for it in the “Value” field. If you desire to have this variable be dynamically altered in different calls, leave it blank. Further, you can have the variable be ‘private’, that is, not visible out of the scope of the particular action river by checking the checkbox (in the case of it possibly containing sensitive information or authentication credentials). Click the “Add Variable” button to create the variable.:
- Next, you will be able to use the {my_variable} or any other variables that you create in any field that you desire to be dynamic when filling out the fields for your api as seen below:
Using the Parameters in Multi-Action Rivers
One of the many advantages of parametrizing your action rivers is being able to use the stored variables from previous steps in multi-step API calls. For example, you may make a GET request to an API endpoint to get the authorization credentials, which you then store in a variable which gets inserted into a downstream API call to POST data to a web endpoint.
-
Create a new Action River, and select Multi-Action from the two options.
-
Click on the button on the right and add variable names that you wish to store from the workflow (they must match the names of the output variable of a rest action exactly).
-
Create steps in your multi action by calling Rest Actions sequentially and entering the input and output parameters.
-
Here, we can see how the output variable of Action_Step_1 ({report_id}) is being passed into the inputs of Action_Step_2 ({Action_Step_2.report_id}). Ensure that the output variables of an action step that you want to reference in subsequent action steps are written in the following format: <step_name>.<variable_name>) in the referencing action step as seen below: