0
0
Postmantesting~10 mins

Request headers in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test sends an HTTP GET request with custom request headers using Postman. It verifies that the server receives the headers correctly and responds with status 200.

Test Code - Postman
Postman
pm.test("Verify response status and headers", function () {
    pm.response.to.have.status(200);
    pm.expect(pm.request.headers.get('X-Custom-Header')).to.eql('TestValue');
    pm.expect(pm.request.headers.get('Accept')).to.eql('application/json');
});
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Open Postman and create a new GET request to https://api.example.com/dataPostman UI shows the new GET request with the URL entered-PASS
2Add request headers: 'X-Custom-Header' with value 'TestValue' and 'Accept' with value 'application/json'Headers tab shows the two headers correctly added-PASS
3Send the request by clicking the Send buttonPostman sends the HTTP GET request with the headers to the server-PASS
4Receive the response from the serverResponse tab shows status 200 and response bodyVerify response status is 200PASS
5Run test script to verify request headers were sent correctlyTest script executes in Postman test runnerCheck that 'X-Custom-Header' equals 'TestValue' and 'Accept' equals 'application/json'FAIL
Failure Scenario
Failing Condition: Request headers are missing or have incorrect values
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after sending the request?
AThat the request method is POST
BThat the response body contains specific data
CThat the response status is 200 and headers were sent correctly
DThat the server redirects to another URL
Key Result
Always verify that custom request headers are correctly set before sending the request to ensure the server receives expected information.