0
0
PostmanHow-ToBeginner ยท 3 min read

How to Set Content-Type Header in Postman Quickly

In Postman, set the Content-Type header by going to the Headers tab and adding a key named Content-Type with the desired value like application/json. This tells the server what format your request body is in.
๐Ÿ“

Syntax

To set the Content-Type header in Postman, add a header with the key Content-Type and set its value to the media type of your request body.

  • Content-Type: The header key that specifies the data format.
  • Value: The MIME type like application/json, application/x-www-form-urlencoded, or text/plain.
http
Content-Type: application/json
๐Ÿ’ป

Example

This example shows how to set the Content-Type header to application/json in Postman when sending a JSON request body.

http
POST /api/users HTTP/1.1
Host: example.com
Content-Type: application/json

{
  "name": "Alice",
  "email": "alice@example.com"
}
Output
HTTP/1.1 201 Created { "id": 123, "name": "Alice", "email": "alice@example.com" }
โš ๏ธ

Common Pitfalls

Common mistakes when setting Content-Type in Postman include:

  • Not setting the header at all, causing the server to misinterpret the data.
  • Setting the wrong Content-Type value that does not match the request body format.
  • Duplicating the header or having conflicting headers.

Always ensure the Content-Type matches your request body format exactly.

http
Wrong way:
Content-Type: text/plain

{"name":"Alice"}

Right way:
Content-Type: application/json

{"name":"Alice"}
๐Ÿ“Š

Quick Reference

Content-Type ValueDescriptionWhen to Use
application/jsonJSON formatSending JSON data in request body
application/x-www-form-urlencodedForm dataSubmitting form data as key-value pairs
multipart/form-dataFile uploadUploading files with form data
text/plainPlain textSending raw text data
โœ…

Key Takeaways

Always set the Content-Type header in Postman to match your request body format.
Use the Headers tab in Postman to add or edit the Content-Type key and value.
Common Content-Type values include application/json and application/x-www-form-urlencoded.
Incorrect or missing Content-Type headers can cause server errors or misinterpretation.
Check your request body format and set Content-Type accordingly for successful API calls.