Update user information using PUT request
Preconditions (2)
✅ Expected Result: Response status code is 200 OK and response body contains updated user information with name 'John Doe' and email 'john.doe@example.com'
pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); const responseJson = pm.response.json(); pm.test('Response has updated name', function () { pm.expect(responseJson.name).to.eql('John Doe'); }); pm.test('Response has updated email', function () { pm.expect(responseJson.email).to.eql('john.doe@example.com'); });
The first test checks that the HTTP status code returned is 200, which means the update was successful.
Then, the response body is parsed as JSON to access its properties.
Next, two tests verify that the 'name' and 'email' fields in the response match the updated values sent in the PUT request.
This ensures the API correctly updated the user information.
Now add data-driven testing with 3 different user updates using Postman Collection Runner
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