Postman pre-request script setting dynamic ID using random number and saving it as a collection variable for API test automation.

The image captures a scripting panel within Postman’s “Pre-request Script” tab, used during API test automation. It demonstrates how a script dynamically generates a new ID by combining a random number ({{randomInt}}) with a prefix (“NEW”), then saves it as a collection variable named “Id”. This technique enables dynamic data generation, which is critical in advanced API workflows like chaining requests, avoiding hard-coded data, and improving test coverage. This is a core part of building scalable, automated test suites in Postman.

×

Table Of Content