Send POST request with form-data body and verify response
Preconditions (3)
✅ Expected Result: Response status code is 200 OK and response body contains confirmation message 'Upload successful for user testuser'
pm.test('Status code is 200', () => { pm.response.to.have.status(200); }); pm.test('Response body contains confirmation message', () => { const responseJson = pm.response.json(); pm.expect(responseJson.message).to.eql('Upload successful for user testuser'); });
The first test checks that the response status code is exactly 200, which means the request was successful.
The second test parses the response body as JSON and verifies that the 'message' field matches the expected confirmation text.
Using pm.test groups assertions with clear names, making test results easy to understand.
Now add data-driven testing with 3 different usernames and files
form-data body in Postman?Key: username, Value: alice, Type: Text
Key: avatar, Value: (file selected), Type: File
photo.jpg and resume.pdf. How should you configure the form-data body in Postman to correctly send all data?Pass the test and this pattern moves unknown