0
0
Postmantesting~5 mins

Why body format matches API expectations in Postman

Choose your learning style9 modes available
Introduction

We use the right body format to make sure the API understands our request. If the format is wrong, the API may not work or give errors.

When sending data to create a new user in an app
When updating information like a profile or settings
When testing an API endpoint that expects JSON or form data
When automating API tests to check if the server accepts the data
When debugging why an API call is failing due to bad data format
Syntax
Postman
POST /endpoint HTTP/1.1
Content-Type: application/json

{
  "key": "value"
}

The Content-Type header tells the API what format the body is in.

Common formats are JSON, XML, or form-data.

Examples
Sending JSON data with user details.
Postman
POST /users HTTP/1.1
Content-Type: application/json

{
  "name": "Alice",
  "age": 30
}
Sending form data for login.
Postman
POST /login HTTP/1.1
Content-Type: application/x-www-form-urlencoded

username=alice&password=1234
Sample Program

This request sends product details in JSON format. The API expects JSON, so it will accept and process this data.

Postman
POST /api/products HTTP/1.1
Host: example.com
Content-Type: application/json

{
  "productName": "Book",
  "price": 12.99
}
OutputSuccess
Important Notes

Always check the API documentation for the expected body format.

Using the wrong format can cause errors like 400 Bad Request.

Postman helps set the correct Content-Type automatically when you choose the body type.

Summary

APIs need the body in the right format to understand your data.

Set the Content-Type header to match the body format.

Use tools like Postman to help format and send requests correctly.