Send a GET request to retrieve user data
Preconditions (2)
✅ Expected Result: Response status code is 200 OK and the response body contains user data with id 1
pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); pm.test('Response has user id 1', function () { const jsonData = pm.response.json(); pm.expect(jsonData.id).to.eql(1); });
The first test checks that the HTTP status code returned by the API is 200, which means the request was successful.
The second test parses the JSON response body and verifies that the user id field equals 1, confirming the correct user data was returned.
Using pm.test allows grouping assertions with descriptive names for clear test reports.
This script runs automatically after the request is sent in Postman.
Now add data-driven testing with 3 different user IDs (1, 2, 3) to verify each returns status 200 and correct user id
GET request in Postman?https://api.example.com/users/1 in Postman. The response body is {"id":1,"name":"Alice"} and status code is 200. What does this mean?Pass the test and this pattern moves unknown