0
0
Postmantesting~5 mins

Form-data body in Postman

Choose your learning style9 modes available
Introduction

Form-data body lets you send data like files and text in a way web servers expect from forms. It helps test how your app handles user input.

When testing file uploads in a web form.
When sending mixed data types like text and images together.
When simulating a user submitting a form with multiple fields.
When API expects multipart/form-data content type.
When testing how backend processes form submissions.
Syntax
Postman
POST /upload HTTP/1.1
Host: example.com
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="field1"

value1
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain

(file content here)
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Each part is separated by a boundary string.

Use Content-Disposition to name fields and files.

Examples
Sends a simple text field named 'username' with value 'alice'.
Postman
Key: username
Value: alice
Type: text
Sends a file named 'profile_pic' as part of the form-data.
Postman
Key: profile_pic
Value: (select file)
Type: file
Sends a text field 'bio' with a short description.
Postman
Key: bio
Value: Hello, I am Alice.
Type: text
Sample Program

This test sends a form with a text field 'name' and a file 'avatar'. It checks if the server accepts both correctly.

Postman
POST /submit HTTP/1.1
Host: api.example.com
Content-Type: multipart/form-data; boundary=----Boundary123

------Boundary123
Content-Disposition: form-data; name="name"

John Doe
------Boundary123
Content-Disposition: form-data; name="avatar"; filename="avatar.png"
Content-Type: image/png

(binary data here)
------Boundary123--
OutputSuccess
Important Notes

Always set the correct Content-Type header with boundary.

Use Postman's form-data tab to add fields easily without manual formatting.

Files must be selected properly to test upload functionality.

Summary

Form-data body is used to send files and text like a real form.

It uses boundaries to separate parts of data.

Postman helps create form-data requests easily for testing APIs.