? Request Body Types in Postman
? Quick Overview
In Postman, the request body is used to send data from the client to the server. Different APIs expect data in different formats. Postman supports multiple request body types, with the most commonly used being Raw JSON, form-data, and x-www-form-urlencoded.
? Key Concepts
- Request body is mainly used with POST, PUT, and PATCH methods
- Correct body type is essential for API to process data
- Content-Type header changes based on body type
- Postman auto-generates headers for most body formats
? Syntax / Theory
Each request body type has its own structure and use case:
- Raw JSON → Structured data (most modern APIs)
- form-data → Files + key-value pairs
- x-www-form-urlencoded → Simple form submissions
? Code Example(s)
? Raw JSON
? View Code Example
{
"username": "admin",
"password": "123456"
}
? form-data
? View Code Example
username=admin
profile_image=photo.png
? x-www-form-urlencoded
? View Code Example
username=admin&password=123456
? Live Output / Explanation
If the body format matches what the server expects, the API processes the request successfully and returns a response such as status 200 OK or 201 Created.
? Interactive Example
Try switching between body types below to see how the code and headers change based on your input.
? Use Cases
- Raw JSON → REST APIs, mobile apps, SPAs
- form-data → File uploads, images, documents
- x-www-form-urlencoded → Login forms, legacy APIs
? Tips & Best Practices
- Always confirm API documentation before choosing body type
- Use Raw JSON for clean and readable requests
- Avoid x-www-form-urlencoded for complex nested data
? Try It Yourself
- Create a POST request using all three body types
- Observe headers generated by Postman
- Test same API with different body formats