Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Postman Tutorial Part 7 – Difference Between ‘Accept’ and ‘Content-Type’ HTTP Headers

Posted on 02/19/2025 By admin

“Accept” and “Content-Type” are HTTP Headers which control input and output formats. “Accept” is a request header and “Content-Type” is both request and response header. Let’s see the difference between these headers:

Let’s understand it using a real time example. We must have submitted final year projects in our college and there were a defined format to submit it. For example say format was PDF or printed and binded book. A defined Format makes it easier to understand. The same case is with HTTP methods. When a client sends a request to a server, server returns response and this response may be in any format. So client may mention desired response format using “Accept” request header. If no Accept header is present in the request, the server sends default or pre-configured representation type. So mentioning “Accept” header is optional in request.

As per RFC-7231, The “Accept” header field can be used by user agents to specify response media types that are acceptable. Accept header fields can be used to indicate that the request is specifically limited to a small set of desired types. Some values of Accept headers are application/json , application/pdf, image/gif etc.

Let’s see Accept header in action:

  1. When we don’t mention “Accept” header:

2. When we mention “Accept” header as “application/xml”:

3. When we mention “Accept” header with format which requested API doesn’t support:

We need to send request body to server to get a response. Request body can be JSON , xml , file etc. So using Content-Type header in request headers, we mention in which format we are sending data to server. Some values of Content-Type headers are application/json , application/pdf etc.

In below image, we can see that I have set “Content-Type” as “application/json” and in Body I am passing json data.

If there is mismatch in mentioned Content-Type and actual type of Request body, it may throw an error depends on behavior of requested API.

Note: Content-Type is not only request header. Server also sends this header as response header with the value as asked format or default format.

Note- If we mention “Content-Type” in a GET request, we will not get any error as GET method does not have any body so it is meaningless. It was asked in interview so mentioned here.

More about API Testing in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below.If you like my posts, please like, comment, share and subscribe.#ThanksForReading

#HappyApiTesting

Uncategorized

Post navigation

Previous Post: Contact
Next Post: TestNG Tutorials 21: Why Don’t We Require a Main Method In TestNG class For Execution Of Methods?

Related Posts

Using Thread.sleep() in Selenium WebDriver Uncategorized
TestNG Tutorials 7: How To Create Customized TestNG XML? Uncategorized
June 25, 2019 – Make Selenium Easy Uncategorized
SkipExceptionFailed – Make Selenium Easy Uncategorized
Learn Selenium With Quiz – Advance Level 7 – XPath – Make Selenium Easy Uncategorized
REST Assured Tutorial 49 – How To Retrieve Single and MultiValue Headers From Response Using Rest Assured Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark