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.
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.
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'); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Open Postman and create a new GET request to https://api.example.com/data | Postman UI shows the new GET request with the URL entered | — | PASS |
| 2 | Add request headers: 'X-Custom-Header' with value 'TestValue' and 'Accept' with value 'application/json' | Headers tab shows the two headers correctly added | — | PASS |
| 3 | Send the request by clicking the Send button | Postman sends the HTTP GET request with the headers to the server | — | PASS |
| 4 | Receive the response from the server | Response tab shows status 200 and response body | Verify response status is 200 | PASS |
| 5 | Run test script to verify request headers were sent correctly | Test script executes in Postman test runner | Check that 'X-Custom-Header' equals 'TestValue' and 'Accept' equals 'application/json' | FAIL |
Authorization with value Bearer token123 in Postman?Key: Value.Content-Type: application/jsonAccept: application/xmlContent-Type = application/json but the server returns a 415 Unsupported Media Type error. What is the likely problem?Content-Type: application/json to tell server data format sent is JSON.Authorization: ApiKey [key] or similar; here Authorization: ApiKey 12345 is correct.Pass the test and this pattern moves unknown