Bird
Raised Fist0
Postmantesting~20 mins

Request headers in Postman - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Request Headers Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding the purpose of request headers

Which of the following best describes the main purpose of HTTP request headers in API testing?

AThey carry metadata about the request such as content type, authorization, and caching policies.
BThey contain the actual data payload sent to the server in the request body.
CThey specify the IP address of the client making the request.
DThey define the server's response format and status codes.
Attempts:
2 left
💡 Hint

Think about what extra information is sent along with the request but is not the main data.

❓ Predict Output
intermediate
2:00remaining
Output of a Postman test script checking a header

Given the following Postman test script, what will be the test result if the response header Content-Type is application/json; charset=utf-8?

Postman
pm.test('Content-Type is application/json', () => {
  pm.response.to.have.header('Content-Type', 'application/json');
});
ATest fails because the header value does not exactly match 'application/json'.
BTest passes because the header contains 'application/json' as part of its value.
CTest fails because the header 'Content-Type' is missing.
DTest passes because Postman ignores charset in header value comparisons.
Attempts:
2 left
💡 Hint

Check if the test checks for exact match or partial match of the header value.

❓ locator
advanced
2:00remaining
Best practice for locating a header in Postman test scripts

Which of the following is the best way to check if the Authorization header exists in a Postman response?

Apm.response.headers.get('Authorization') !== undefined
Bpm.response.headers['Authorization'] !== null
Cpm.response.headers.find(header => header.key === 'Authorization')
Dpm.response.headers.has('Authorization')
Attempts:
2 left
💡 Hint

Look for the method designed to check header existence directly.

❓ assertion
advanced
2:00remaining
Correct assertion for checking JSON content type header

Which Postman test assertion correctly verifies that the Content-Type header starts with application/json (ignoring charset)?

Apm.expect(pm.response.headers.get('Content-Type')).to.include('application/json');
Bpm.expect(pm.response.headers.get('Content-Type')).to.match(/^application\/json/);
Cpm.expect(pm.response.headers.get('Content-Type')).to.equal('application/json');
Dpm.expect(pm.response.headers.get('Content-Type')).to.be.a('string');
Attempts:
2 left
💡 Hint

Think about how to check the start of a string with possible extra text after it.

❓ framework
expert
3:00remaining
Handling dynamic request headers in automated tests

In an automated API test suite using Postman, you need to send a dynamic X-Request-ID header with a unique UUID for each request. Which approach is best to implement this?

AHardcode a fixed UUID value in the header for all requests to keep tests consistent.
BAdd the UUID generation logic in the Tests script after the request is sent.
CUse a Pre-request Script to generate a UUID and set it as an environment variable, then reference it in the header value.
DManually enter a new UUID value in the Headers tab before each test run.
Attempts:
2 left
💡 Hint

Consider when and where to generate dynamic data before sending the request.

Practice

(1/5)
1. What is the main purpose of request headers in Postman API calls?
easy
A. To send extra information like authentication or data format
B. To write the body content of the request
C. To specify the URL of the API endpoint
D. To display the response status code

Solution

  1. Step 1: Understand what request headers do

    Request headers add extra info to the API call, such as authentication tokens or content type.
  2. Step 2: Differentiate headers from other parts

    Headers are not the body or URL; they are key-value pairs sent with the request.
  3. Final Answer:

    To send extra information like authentication or data format -> Option A
  4. Quick Check:

    Request headers = extra info [OK]
Hint: Headers add info like auth or format, not body or URL [OK]
Common Mistakes:
  • Confusing headers with request body
  • Thinking headers specify the URL
  • Assuming headers show response info
2. Which of the following is the correct way to add a header named Authorization with value Bearer token123 in Postman?
easy
A. Authorization -> Bearer token123
B. Authorization = Bearer token123
C. Authorization Bearer token123
D. Authorization: Bearer token123

Solution

  1. Step 1: Recall header syntax in HTTP

    Headers use a colon ':' to separate key and value, like Key: Value.
  2. Step 2: Match the correct syntax

    Authorization: Bearer token123 uses colon correctly; others use wrong separators or miss colon.
  3. Final Answer:

    Authorization: Bearer token123 -> Option D
  4. Quick Check:

    Headers use colon ':' between key and value [OK]
Hint: Headers use colon ':' between key and value [OK]
Common Mistakes:
  • Using '=' instead of ':'
  • Omitting colon separator
  • Using arrows or spaces only
3. Given this Postman header setup:
Content-Type: application/json
Accept: application/xml
What will the server expect and respond with?
medium
A. Server expects XML data and responds with JSON
B. Server expects JSON data and responds with XML
C. Server expects and responds with JSON
D. Server expects and responds with XML

Solution

  1. Step 1: Understand Content-Type header

    Content-Type tells the server the format of data sent by client; here it is JSON.
  2. Step 2: Understand Accept header

    Accept tells the server what response format client wants; here it is XML.
  3. Final Answer:

    Server expects JSON data and responds with XML -> Option B
  4. Quick Check:

    Content-Type = sent format, Accept = response format [OK]
Hint: Content-Type = sent data, Accept = desired response [OK]
Common Mistakes:
  • Mixing up Content-Type and Accept meanings
  • Assuming both headers mean the same
  • Ignoring Accept header
4. You added a header in Postman as Content-Type = application/json but the server returns a 415 Unsupported Media Type error. What is the likely problem?
medium
A. You forgot to add the Authorization header
B. The value 'application/json' is invalid
C. Header syntax is incorrect; should use colon ':' instead of '='
D. The server does not support JSON at all

Solution

  1. Step 1: Check header syntax

    Headers must use colon ':' to separate key and value, not '='.
  2. Step 2: Understand server error 415

    415 means server rejects media type due to wrong or missing Content-Type header.
  3. Final Answer:

    Header syntax is incorrect; should use colon ':' instead of '=' -> Option C
  4. Quick Check:

    Wrong header syntax causes 415 error [OK]
Hint: Use ':' not '=' in headers to avoid 415 error [OK]
Common Mistakes:
  • Using '=' instead of ':' in headers
  • Assuming server rejects JSON always
  • Ignoring header syntax errors
5. You want to send a POST request with JSON data and an API key for authentication in Postman. Which header setup is correct?
hard
A. Content-Type: application/json and Authorization: ApiKey 12345
B. Accept: application/json and Authorization: 12345
C. Content-Type: text/plain and ApiKey: 12345
D. Authorization: Bearer 12345 only

Solution

  1. Step 1: Identify correct content type for JSON data

    Use Content-Type: application/json to tell server data format sent is JSON.
  2. Step 2: Use proper authorization header format

    API keys often use Authorization: ApiKey [key] or similar; here Authorization: ApiKey 12345 is correct.
  3. Final Answer:

    Content-Type: application/json and Authorization: ApiKey 12345 -> Option A
  4. Quick Check:

    Content-Type + Authorization with correct syntax [OK]
Hint: Use Content-Type for data and Authorization for API key [OK]
Common Mistakes:
  • Using wrong Content-Type for JSON
  • Putting API key in wrong header
  • Omitting Content-Type header
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard