Scripting an API Functional Test in the UI

This is an advanced, alternative option for Creating an API Functional Test, so make sure to start with that guide, which will then lead into this guide.

We are building something new

under construction!

Starting February 2022, the API Functional testing feature has been deprecated. Depending on your subscription plan, you may still be able to run existing tests but can no longer create new ones. Please use BlazeMeter API Monitoring to create and run your API Functional Tests going forward.


If you prefer to code rather than build your API test in the UI, then simply click the toggle to the right of the scenario name from UI mode to scripting mode ("</>").

Write the Script

In this mode, you can write your test as a Taurus YAML script directly in BlazeMeter. Any changes that you will make in the editor will also show up in the UI and vice versa.

Taurus YAML script

Validate the Script

While editing the script, a basic YAML syntax check is running in the background. If the script is invalid, you won't be able to switch back to the UI (the toggle will be greyed out).
UI/Script toggle

When this happens, hover the mouse pointer over the UI button to see an error message. In the following example, the user has removed the scenario name entirely from the script:

the Script Editor

If you see an error message saying, "Current configuration is in malformed structure" and "bad indentation", also ensure that you are using spaces and not tabs for indentation.

Once you have completed your script, click the "Validate" button below the editor to verify your script is valid. The button changes to either "Failed" or "Passed". Click "Failed" or "Passed" to re-validate the script.
the Validate Script button

Finally, you can download a copy of the YAML script using the button to the right of the "Validate" button.

the download script button

Now you can run the API functional test.

Common Functions

The Common Functions dropdown offers some helper functions that make it easier to create certain requests. Click the Copy button to copy an example of a function that implements base64 or URL encoding, or generating a random number or string. Now you can paste the function into any field and define its arguments.

Upload a File

Files can be used in different ways in your test scenario. For example, you can use a CSV file as a data source, provide a file for a request body, use a file as a form attachment, or run pre- and post-processing scripts.

  1. Click the Upload File button, then select a file from your computer.
  2. Once a file is uploaded, click the arrow to open a drop-down menu, then click the copy button.
  3. You can now paste the file name in your script.

When using a CSV file, only the first row of data will be used.

Here are a few examples of how this feature can be used:

  • Use a file as a data source:
    data-sources: # list of external data sources 
    - path: user-data.csv # this is full form, path option is required
    variable-names: first,second # delimiter-separated list of variable names, empty by default
  • Use a file in a request body:

    body-file: user-data.txt # this file contents will be used as post body
  • Use a file as a form attachment:

    upload-files: # attach files to form (and enable multipart/form-data)
    - param: summaryReport # form parameter name
      path: user-data.pdf # pasted path to file
      mime-type: application/pdf # optional, Taurus will attempt to guess it automatically
  • Use a file as a pre- or post-processing script:

    jsr223: 
    - execute: before
    language: beanshell
    parameters: null
    script-file: username_password_create.bsh
    - execute: after
    language: beanshell
    parameters: null
    script-file: write_users_to_CSV.bsh

Select a Test Location

Click to open the "Select Test Location" drop-down menu, where you can select a region where you want the test executed from.

select test location menu

Doing so will automatically add the location to the script.

a script with an added locations entry

Select a Snippet

You may optionally use the "Snippets" drop-down menu (which are the equivalent of using the templates scenario option of the same name when building the test via the UI). Like their templates graphical cousins, snippets are a great way to make scripting tests faster and easier, including snippets for different types of authentication.

For example, consider the following basic scenario:

a basic scenario example

Add a "Basic Auth" snippet:

the snippets menu

And it's added to the script for you:

a script with an added header entry

Mock Services Configuration

Optionally, select a Mock Service Template that contains the transactions to load into the selected Mock Service. For more information, see Adding a Mock Service to a Test.

DNS Override

The DNS Override option works for Functional Tests in the exact same manner it does for Performance Tests. Check out our guide on the DNS Override for details.