Verify API accepts x-www-form-urlencoded body and returns success
Preconditions (2)
✅ Expected Result: Response status code is 200 and response body contains JSON with key 'message' and value 'Login successful'
pm.test('Status code is 200', function () { pm.response.to.have.status(200); }); pm.test('Response has success message', function () { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('message', 'Login successful'); });
The first test checks that the HTTP status code returned by the API is 200, which means the request was successful.
The second test parses the response body as JSON and verifies that it contains a key named 'message' with the exact value 'Login successful'.
These tests ensure the API correctly processes the x-www-form-urlencoded body and returns the expected success response.
Now add data-driven testing with 3 different username and password combinations
x-www-form-urlencoded body type do in Postman?x-www-form-urlencoded sends form data as key-value pairs joined by '&' in the request body, similar to how HTML forms send data.x-www-form-urlencoded uses key-value pairs joined by '&'.x-www-form-urlencoded body tab?x-www-form-urlencoded body tab shows two columns: one for keys and one for values.x-www-form-urlencoded body:username: user1password: pass@123x-www-form-urlencoded body in Postman with keys and values, but the server responds with a 400 Bad Request error. What is the most likely cause?x-www-form-urlencoded data, the Content-Type header must be set to application/x-www-form-urlencoded so the server knows how to parse the body.x-www-form-urlencoded body in Postman with keys username and password. The password contains spaces and special characters like pass word@123!. How should you prepare the body to ensure the server receives it correctly?x-www-form-urlencoded body type.Pass the test and this pattern moves unknown