Verify API documentation helps users successfully call the API
Preconditions (2)
✅ Expected Result: The API request succeeds with status 200 and returns the expected user data as shown in the documentation
pm.test('Status code is 200', () => { pm.response.to.have.status(200); }); pm.test('Response has user id and name', () => { const jsonData = pm.response.json(); pm.expect(jsonData).to.have.property('id'); pm.expect(jsonData).to.have.property('name'); });
The first test checks that the API response status code is 200, which means the request was successful.
The second test verifies that the response body contains the expected user data fields 'id' and 'name' as documented.
These tests use Postman's built-in pm object and assertion library to confirm the API behaves as described in the documentation.
Now add data-driven testing with 3 different user IDs to verify the API returns correct data for each
{ "userId": 123, "name": "John" } shows a JSON object, which is typical for API examples.{
"id": 10,
"status": "active"
}Pass the test and this pattern moves unknown