Automate API test using Postman visual workflow
Preconditions (3)
✅ Expected Result: The visual workflow runs successfully, both API requests return expected responses, and tests pass confirming response status and body structure
/* Postman Visual Workflow JSON export example */ { "info": { "name": "User API Tests", "_postman_id": "1234-5678-9012-3456", "description": "Collection to test User API endpoints", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, "item": [ { "name": "Get Users", "request": { "method": "GET", "header": [], "url": { "raw": "{{baseUrl}}/users", "host": ["{{baseUrl}}"], "path": ["users"] } }, "event": [ { "listen": "test", "script": { "exec": [ "pm.test('Status code is 200', () => {", " pm.response.to.have.status(200);", "});", "pm.test('Response is JSON array', () => {", " pm.expect(pm.response.json()).to.be.an('array');", "});" ], "type": "text/javascript" } } ] }, { "name": "Create User", "request": { "method": "POST", "header": [ { "key": "Content-Type", "value": "application/json" } ], "body": { "mode": "raw", "raw": "{\n \"name\": \"John Doe\",\n \"email\": \"john.doe@example.com\"\n}" }, "url": { "raw": "{{baseUrl}}/users", "host": ["{{baseUrl}}"], "path": ["users"] } }, "event": [ { "listen": "test", "script": { "exec": [ "pm.test('Status code is 200', () => {", " pm.response.to.have.status(200);", "});", "pm.test('Response has created user', () => {", " const jsonData = pm.response.json();", " pm.expect(jsonData).to.have.property('name', 'John Doe');", " pm.expect(jsonData).to.have.property('email', 'john.doe@example.com');", "});" ], "type": "text/javascript" } } ] } ], "event": [ { "listen": "prerequest", "script": { "exec": [], "type": "text/javascript" } }, { "listen": "test", "script": { "exec": [], "type": "text/javascript" } } ], "variable": [ { "key": "baseUrl", "value": "https://api.example.com" } ] } /* Visual Workflow Steps in Postman UI */ // 1. Add 'Get Users' request // 2. Add 'Create User' request // 3. Connect 'Get Users' to 'Create User' to run sequentially // 4. Run the workflow and observe test results in Postman Runner
This Postman collection defines two requests: a GET to fetch users and a POST to create a user. Each request has test scripts to check the response status and body content.
Using environment variable baseUrl allows easy switching of API endpoints without changing code.
The visual workflow connects these requests so they run in order, simulating a real user flow.
Assertions ensure the API behaves as expected, and organizing requests in a collection keeps tests maintainable.
Now add data-driven testing with 3 different user data inputs for the POST /users request
Pass the test and this pattern moves unknown