Test Overview
This test sends a GET request to a REST API endpoint to retrieve user data. It verifies that the response status is 200 OK and that the response body contains the expected user ID and name.
This test sends a GET request to a REST API endpoint to retrieve user data. It verifies that the response status is 200 OK and that the response body contains the expected user ID and name.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has correct user data", function () { const jsonData = pm.response.json(); pm.expect(jsonData.id).to.eql(1); pm.expect(jsonData.name).to.eql("John Doe"); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Send GET request to https://api.example.com/users/1 | Postman sends HTTP GET request to the API endpoint | - | PASS |
| 2 | Receive HTTP response from the server | Response received with status code 200 and JSON body {"id":1,"name":"John Doe"} | - | PASS |
| 3 | Check that response status code is 200 | Response status code is 200 OK | pm.response.to.have.status(200) | PASS |
| 4 | Parse response JSON and verify user id and name | Response JSON parsed as {id:1, name:"John Doe"} | pm.expect(jsonData.id).to.eql(1) and pm.expect(jsonData.name).to.eql("John Doe") | PASS |