0
0
Postmantesting~20 mins

Response headers in Postman - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Response Headers Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the value of the Content-Type header?
You send a GET request to an API endpoint. The response headers include:
Content-Type: application/json; charset=utf-8
Cache-Control: no-cache

What is the exact value of the Content-Type header?
Atext/html; charset=utf-8
Bapplication/json
Capplication/json; charset=utf-8
Dno-cache
Attempts:
2 left
💡 Hint
Look carefully at the full value after the colon in the Content-Type header.
assertion
intermediate
1:30remaining
Which assertion correctly checks the Cache-Control header?
You want to write a Postman test to verify the response header Cache-Control is exactly 'no-store'. Which assertion code is correct?
Postman
pm.test('Cache-Control is no-store', () => {
    pm.expect(pm.response.headers.get('Cache-Control')).to.eql('no-store');
});
Apm.expect(pm.response.headers.get('cache-control')).to.eql('no-store');
Bpm.expect(pm.response.headers.get('Cache-Control')).to.eql('no-store');
Cpm.expect(pm.response.headers.get('Cache-Control')).to.equal('no-cache');
Dpm.expect(pm.response.headers.get('Cache-Control')).to.be.undefined;
Attempts:
2 left
💡 Hint
Header names are case-insensitive but use the exact header name casing for clarity.
🔧 Debug
advanced
2:00remaining
Why does this Postman test fail to detect the X-RateLimit-Remaining header?
Consider this test code:
pm.test('Rate limit remaining is 10', () => {
    pm.expect(pm.response.headers.get('x-ratelimit-remaining')).to.eql('10');
});

The test fails even though the response headers include:
X-RateLimit-Remaining: 10

What is the most likely reason?
AHeader names are case-sensitive in Postman, so 'x-ratelimit-remaining' does not match 'X-RateLimit-Remaining'.
BThe header is missing from the response, so get() returns null.
CThe header value is a number, but the test compares it to a string '10'.
DThe header name has extra spaces causing mismatch.
Attempts:
2 left
💡 Hint
Check how Postman treats header name casing in the get() method.
🧠 Conceptual
advanced
1:30remaining
What does the 'Access-Control-Allow-Origin' header control?
In API testing, what is the purpose of the 'Access-Control-Allow-Origin' response header?
AIt controls which domains are allowed to access the resource via browsers (CORS policy).
BIt sets the cache expiration time for the response.
CIt defines the content type of the response body.
DIt specifies the allowed HTTP methods for the resource.
Attempts:
2 left
💡 Hint
Think about browser security and cross-domain requests.
framework
expert
2:30remaining
Which Postman test code correctly asserts multiple response headers?
You want to check that the response headers include:
Content-Type: application/json
Cache-Control: no-cache

Which Postman test code correctly asserts both headers in one test?
A
pm.test('Headers check', () => {
  pm.response.to.have.headers({
    'Content-Type': 'application/json',
    'Cache-Control': 'no-cache'
  });
});
B
pm.test('Headers check', () => {
  pm.response.to.have.header('Content-Type', 'application/json');
  pm.response.to.have.header('Cache-Control', 'no-cache');
});
C
pm.test('Headers check', () => {
  pm.expect(pm.response.headers.get('Content-Type')).to.equal('application/json');
  pm.expect(pm.response.headers.get('Cache-Control')).to.equal('no-cache');
});
D
pm.test('Headers check', () => {
  pm.expect(pm.response.headers.get('Content-Type')).to.eql('application/json');
  pm.expect(pm.response.headers.get('Cache-Control')).to.eql('no-cache');
});
Attempts:
2 left
💡 Hint
Check which Postman assertion methods support multiple headers at once.