Uploading binary files lets you send images, documents, or any file type to a server. It helps test if the server accepts and processes files correctly.
Binary file upload in Postman
POST /upload HTTP/1.1 Host: example.com Content-Type: multipart/form-data; boundary=----WebKitFormBoundary ------WebKitFormBoundary Content-Disposition: form-data; name="file"; filename="example.png" Content-Type: image/png <binary data here> ------WebKitFormBoundary--
In Postman, use the 'Body' tab, select 'form-data', add key 'file' (type: File), and choose your file to upload.
The Content-Type header is set automatically by Postman when using form-data with file.
POST https://api.example.com/upload Body tab > form-data > key: "file" (type: File) > select file 'photo.jpg'
POST https://api.example.com/upload Body tab > form-data > key: "file" (type: File) > select file 'document.pdf'
This test uploads 'test-image.png' to the server with authorization. It checks if the server accepts the file.
POST https://api.example.com/upload Headers: Authorization: Bearer your_token_here Body: form-data > key: "file" (type: File) > select file 'test-image.png'
Always check the server response to confirm the upload succeeded.
Use meaningful file names to track tests easily.
Binary upload sends the raw file data without encoding it as text.
Binary file upload sends raw files to a server for testing upload features.
In Postman, use the 'form-data' option in the Body tab, set key to 'file' (type: File) to select your file.
Check server responses to verify successful uploads.
Practice
Solution
Step 1: Understand Postman Body tab options
Postman offers multiple Body tab options like form-data, raw, binary, and GraphQL for different request types.Step 2: Identify the correct option for file upload
For uploading raw files such as images or documents, the 'Binary' option is used to send the file as-is.Final Answer:
Binary -> Option CQuick Check:
Binary option = file upload [OK]
- Choosing 'form-data' which is for key-value pairs
- Using 'raw' which sends text data, not files
- Selecting 'GraphQL' which is unrelated to file upload
Solution
Step 1: Identify the correct Body tab for binary upload
Binary upload requires selecting the 'binary' option in the Body tab.Step 2: Understand file selection process
After choosing 'binary', Postman shows a 'Select File' button to browse and pick the file to upload.Final Answer:
Click 'Select File' after choosing 'binary' in Body tab -> Option DQuick Check:
Binary + Select File = correct file upload [OK]
- Trying to upload file in 'form-data' without key
- Pasting file content in 'raw' which is for text
- Entering file path in URL which is invalid
Solution
Step 1: Understand typical server responses for file upload
A successful file upload usually returns HTTP status 200 OK with a confirmation message.Step 2: Analyze other status codes
404 means resource missing, 500 means server error, 401 means unauthorized access; none indicate success.Final Answer:
HTTP 200 OK with success message -> Option AQuick Check:
Success upload = HTTP 200 OK [OK]
- Confusing 404 as success
- Assuming 500 means success
- Ignoring authentication errors like 401
Solution
Step 1: Understand HTTP 400 Bad Request meaning
This status means the server could not understand the request due to invalid syntax or missing data.Step 2: Identify common binary upload mistakes
If no file is selected in the binary Body tab, the request lacks the file data, causing a bad request error.Final Answer:
File was not selected in the binary Body tab -> Option BQuick Check:
Missing file = HTTP 400 Bad Request [OK]
- Assuming server down causes 400 error
- Using wrong HTTP method without checking
- Uploading empty files without validation
Solution
Step 1: Understand Postman test syntax
Postman uses pm.test with a callback function and assertion methods like pm.response.to.have.status(200) to check status codes.Step 2: Evaluate each option's correctness
pm.test('Upload success', () => pm.response.to.have.status(200)); uses correct assertion syntax. pm.test('Upload success', () => pm.response.status === '200'); incorrectly compares number status to string '200'. pm.test('Upload success', () => pm.response.code == '200'); uses wrong property (code is 'OK') and type. pm.test('Upload success', () => pm.response.statusCode === 'OK'); uses invalid statusCode and string.Final Answer:
pm.test('Upload success', () => pm.response.to.have.status(200)); -> Option AQuick Check:
Use pm.response.to.have.status(200) for status check [OK]
- Using equality instead of assertion methods
- Comparing status code as string instead of number
- Using wrong property names for response status
Ready to prove it?
Pass the test and this pattern moves unknown
