0
0
Postmantesting~10 mins

PATCH request in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends a PATCH request to update a user's email address and verifies the response status and updated data.

Test Code - Postman
Postman
pm.test("PATCH request updates user email successfully", function () {
    pm.sendRequest({
        url: 'https://jsonplaceholder.typicode.com/users/1',
        method: 'PATCH',
        header: {
            'Content-Type': 'application/json'
        },
        body: {
            mode: 'raw',
            raw: JSON.stringify({ email: 'newemail@example.com' })
        }
    }, function (err, res) {
        pm.expect(err).to.be.null;
        pm.expect(res).to.have.property('status', 200);
        const jsonData = res.json();
        pm.expect(jsonData).to.have.property('email', 'newemail@example.com');
    });
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test startsPostman test runner is ready-PASS
2Sends PATCH request to https://jsonplaceholder.typicode.com/users/1 with updated email in JSON bodyRequest is sent over network-PASS
3Receives response from serverResponse status code 200 OK, body contains updated user dataCheck response status code is 200PASS
4Parses response JSON and verifies 'email' field is 'newemail@example.com'Response JSON parsed successfullyVerify response JSON has property 'email' with value 'newemail@example.com'PASS
5Test ends with all assertions passedTest report shows success-PASS
Failure Scenario
Failing Condition: Server returns status code other than 200 or response JSON does not contain updated email
Execution Trace Quiz - 3 Questions
Test your understanding
What HTTP method is used in this test to update user data?
APATCH
BPOST
CGET
DDELETE
Key Result
Always verify both the HTTP status code and the response body content to ensure the PATCH request updated the resource correctly.