💡 If you like this website, please share it with your friends and network! 🚀
Back to All Questions
Question 15 of 100
Basic API Testing
Beginner

Q15: What is a Request Header in API Testing?

🏷️Core Concept

What is a Request Header in API Testing?

Key Takeaways & Architecture Summary

  • Contains metadata that configures how the request should be processed.
  • Accept: Declares the data format the client expects back.
  • Content-Type: Declares the media format of the payload being sent.
  • Authorization: Transmits tokens, API keys, or basic credentials.

Direct Answer Summary

A Request Header is a key-value metadata pair sent within the HTTP request header block. It provides essential metadata to the server, detailing the client's identity, authenticating access tokens, configuring payload content formats (via `Content-Type`), declaring expected response formats (via `Accept`), and passing cookie states.

⚠️ Senior Engineering Warning (Red Flag)

Avoid mismatching Content-Type with your payload structure. If you send a JSON string but leave Content-Type as "text/plain", the server may reject it with an HTTP 415 Unsupported Media Type error.

💡 STAR Architectural Explanation & Pro Tip

Headers separate data from transport configuration. This allow proxies, load balancers, and firewalls to authenticate, route, and cache requests without opening the body payload.

PlaywrightApiTest.ts
Playwright API
// Injecting custom headers using Playwright API
await request.get('/api/v1/jobs', {
    headers: {
        'Accept': 'application/json',
        'X-Client-Type': 'Web-App-2026'
    }
});