Test Overview
This test sends a PUT request to update a user's information on the server. It verifies that the server responds with a success status and the updated data matches the request.
This test sends a PUT request to update a user's information on the server. It verifies that the server responds with a success status and the updated data matches the request.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has updated user name", function () { const jsonData = pm.response.json(); pm.expect(jsonData.name).to.eql("John Doe"); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman app is open with the PUT request prepared | — | PASS |
| 2 | PUT request sent to https://api.example.com/users/123 with JSON body {"name": "John Doe", "email": "john@example.com"} | Request is in progress, waiting for server response | — | PASS |
| 3 | Response received with status code 200 and JSON body {"id": 123, "name": "John Doe", "email": "john@example.com"} | Response displayed in Postman | Check if status code is 200 | PASS |
| 4 | Test script runs assertion to verify response status is 200 | Test script executing | pm.response.to.have.status(200) | PASS |
| 5 | Test script runs assertion to verify response JSON 'name' field equals 'John Doe' | Test script executing | pm.expect(jsonData.name).to.eql("John Doe") | PASS |
| 6 | Test ends with all assertions passing | Postman shows test results as passed | — | PASS |
PUT request in Postman?{
"id": 101,
"name": "Coffee Mug",
"price": 12.99
}
If the server replaces the entire product resource with this data, what will be the product's name after the update?id, name, email, and phone. You only want to change the phone number. What is the best practice to avoid accidentally deleting other fields?Pass the test and this pattern moves unknown