Automating API Using API collectionScripts in API Automation

Scripts in API Automation

This article provides detailed information on using Scripts in the Request section tabs of an API project.

How to Use Scripts in API Project

Currently, under the Request Section Tabs>>Scripts section, we only support Pre-request scripts.

When you click the Send button, the pre-request script executes before the actual API request URL is called. This allows you to run JavaScript code for example, using pm.environment.set() to assign a random value or dynamically update environment variables.

Once you click on Send, the data will be stored in the Env. You can view this data under the Env tab.

At present, we support adding dynamic environment data through Pre-request scripts.

Postman request Scripts tab with Pre-request script generating and saving a random number