We frequently run into users who are looking to run an API test multiple times, using a variety of initial variables. For example, the user might be looking to:
- Test the same request against a list of user ids, where user_id is the only query string parameter that changes.
- Test edge cases for an API call. Passing a string to an endpoint that expects an int, or passing special characters to it, and making sure that nothing breaks.
- Share tests and results for multiple variable sets with other teammates for debugging.
We have been able to accommodate this feature for a long time using our Batch Trigger URLs. With a GET request to a Batch Trigger URL, you can pass in an array of objects to specify initial variables for the test, and kick off up to 50 test runs at one time using different sets of variables.
Batch Triggers are pretty easy to use:

But what if you want an easier way to do this than to try to format an API request with a bunch of variables and build a JSON array with the different sets? And how do you match up your responses easily to the different sets of variables? What if we could make this easier?
Using Google Sheets and Runscope Batch Trigger URLs
I was interested in making this process easier for Runscope users, so I created a Google Sheet which leverages a Google Apps Script to take sets of variables and use them with a Runscope Batch Trigger URL to kick off requests:

With this Google Sheet template, you can specify a set of initial variable names and values under Variable Sets. Then, from your Runscope test, you need to get the Trigger ID. It can be found on your test editor, in the environment section under Trigger URL. You only need the Trigger ID, not the full URL:
Once you have your Trigger ID, you can replace the "your_test_trigger_id" cell with its value.
With the Trigger ID and variable names/values setup, the Number of Variables and Number of Sets fields should update automatically. You can then click “Run Tests”, and the Runscope tests will be kicked off with each of the variable sets. The first time you run the test, you will have to give Google permission to run the script.
Behind the scenes, the Google Script is taking the variable names and values and creating the array of objects to use in conjunction with the Batch Trigger URL. The script makes the request, and then pastes the links to the results in the Results row.
If you’d like to see if the tests actually passed, you can add a Runscope API Token, and then click “Get Results”. A second script will take each of the Result API Locations, request the results via the Runscope API, and update the Test Pass/Fail values accordingly.
Note that each time you click "Run Tests" it will clear out the results from prior tests. If you want to store the results, you can duplicate the current sheet, or copy and paste the values to another tool.
Get Your Own Google Sheet to Trigger Tests
If you’d like to take a look at the script that powers the template, you can see it under Tools -> Script editor, or here in this gist.
You can find the Google Sheets template here. You will need to make a copy into your own account, and again, give it permission to run the first time you use it. Please reach out to our awesome support team if you need any help!
Happy testing!