Upload a binary file using Postman
Preconditions (3)
✅ Expected Result: The API responds with a success status code (e.g., 200 or 201) and a confirmation message indicating the file was uploaded successfully
pm.test('Status code is 200 or 201', function () { pm.expect(pm.response.code).to.be.oneOf([200, 201]); }); pm.test('Response contains success message', function () { const jsonData = pm.response.json(); pm.expect(jsonData.message || jsonData.status).to.match(/success|uploaded/i); });
The first test checks that the response status code is either 200 or 201, which means the upload was successful.
The second test parses the JSON response body and verifies it contains a success message or status.
Using pm.expect ensures clear assertion failures if the API does not behave as expected.
These tests run automatically after sending the binary file upload request in Postman.
Now add data-driven testing with 3 different binary files (e.g., image.png, document.pdf, audio.mp3) to upload
Pass the test and this pattern moves unknown