Verify custom request headers are sent and received correctly
Preconditions (2)
✅ Expected Result: The response body contains the header 'X-Test-Header' with value 'TestValue123'
pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); pm.test('Response contains custom header', function () { const jsonData = pm.response.json(); pm.expect(jsonData.headers['x-test-header']).to.eql('TestValue123'); });
The first test checks that the HTTP status code returned is 200, meaning the request was successful.
The second test parses the JSON response body and verifies that the custom header 'X-Test-Header' is present with the exact value 'TestValue123'.
This ensures the header was sent and received correctly by the API.
Now add data-driven testing with 3 different custom header values
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