Adding scripts to API tests
How to add pre-request, test, and flow-level scripts to an API test
This guide outlines how to add pre-request, test, and flow-level scripts to an API test.
Pre-request scripts execute code before a request is made. To add one, open the API Test Editor and take the following steps:
- Click on the test step you'd like to edit on the left-side panel.
- In the Request details section, select the Pre-request tab.
- Edit your script code as needed.
Test scripts run code after a request is made. They can be added in the Validation and variables assignment section:
- In the API Test Editor, click on the step you'd like to edit in the left-side panel.
- Open up the Validation and variable assignment section.
- Select the Test tab.
- Edit your test script as needed.
You can review pre-request and test scripts for individual steps on the Test Details page.
Flow-level scripts are applied on every request in an API test; they include the option for both pre-request and post-request scripts.
To add a flow-level script, click on the pencil icon in the flow title card to open the flow properties modal:
In the modal, you can select the Pre-request or Post-request tab and edit your script code as needed. Close the modal using the X icon when you are happy with the script.
Updated about 1 month ago