Request headers send extra information with your API call. They help the server understand your request better.
When you need to tell the server what type of data you accept, like JSON or XML.
When you want to send authentication details like tokens or API keys.
When you want to specify language or encoding preferences.
When you want to control caching or session information.
When you want to send custom information the server expects.
Syntax
Postman
Key: Value
Headers are key-value pairs.
Keys are case-insensitive; values may be case-sensitive depending on the header.
Examples
This header tells the server you are sending JSON data.
Postman
Content-Type: application/json
This header sends a token to prove who you are.
Postman
Authorization: Bearer your_token_here
This header tells the server you prefer English (US) responses.
Postman
Accept-Language: en-US
Sample Program
This example shows a GET request with headers to accept JSON data and send an authorization token.
Postman
GET https://api.example.com/data
Headers:
Accept: application/json
Authorization: Bearer abc123token
// In Postman, set these headers in the Headers tab before sending the request.
OutputSuccess
Important Notes
Always check the API documentation to know which headers are required.
Headers can affect how the server processes your request and what it returns.
In Postman, headers are easy to add and edit in the Headers tab for each request.
Summary
Request headers send extra info with your API call.
They are key-value pairs like Content-Type or Authorization.
Use headers to control data format, authentication, and preferences.
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
Step 1: Understand what request headers do
Request headers add extra info to the API call, such as authentication tokens or content type.
Step 2: Differentiate headers from other parts
Headers are not the body or URL; they are key-value pairs sent with the request.
Final Answer:
To send extra information like authentication or data format -> Option A
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
Step 1: Recall header syntax in HTTP
Headers use a colon ':' to separate key and value, like Key: Value.
Step 2: Match the correct syntax
Authorization: Bearer token123 uses colon correctly; others use wrong separators or miss colon.
Final Answer:
Authorization: Bearer token123 -> Option D
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
Step 1: Understand Content-Type header
Content-Type tells the server the format of data sent by client; here it is JSON.
Step 2: Understand Accept header
Accept tells the server what response format client wants; here it is XML.
Final Answer:
Server expects JSON data and responds with XML -> Option B
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
Step 1: Check header syntax
Headers must use colon ':' to separate key and value, not '='.
Step 2: Understand server error 415
415 means server rejects media type due to wrong or missing Content-Type header.
Final Answer:
Header syntax is incorrect; should use colon ':' instead of '=' -> Option C
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
Step 1: Identify correct content type for JSON data
Use Content-Type: application/json to tell server data format sent is JSON.
Step 2: Use proper authorization header format
API keys often use Authorization: ApiKey [key] or similar; here Authorization: ApiKey 12345 is correct.
Final Answer:
Content-Type: application/json and Authorization: ApiKey 12345 -> Option A
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 unknownstrongwhile earning +1 Grip toward your certificate.