Test Overview
This test sends a GET request using Postman with a path parameter to retrieve a specific user's details. It verifies that the response status is 200 and the returned user ID matches the path parameter.
This test sends a GET request using Postman with a path parameter to retrieve a specific user's details. It verifies that the response status is 200 and the returned user ID matches the path parameter.
pm.test("Status code is 200", function () { pm.response.to.have.status(200); }); pm.test("Response has correct user ID", function () { const userId = pm.variables.get("userId"); const jsonData = pm.response.json(); pm.expect(jsonData.id).to.eql(parseInt(userId)); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Postman app is open with the GET request configured to https://api.example.com/users/:userId with userId=5 | — | PASS |
| 2 | Send GET request to https://api.example.com/users/5 | Request sent, waiting for response | — | PASS |
| 3 | Receive response with status 200 and JSON body {"id":5, "name":"John Doe"} | Response received in Postman | Check response status is 200 | PASS |
| 4 | Run test to verify response status code | Test script executes | pm.response.to.have.status(200) | PASS |
| 5 | Run test to verify response user ID matches path parameter | Test script executes | pm.expect(jsonData.id).to.eql(5) | PASS |
https://api.example.com/users/{userId}/posts/{postId} and path parameters userId=42 and postId=7, what is the final URL sent by Postman?https://api.example.com/items/{itemId} in Postman but forgot to set the path parameter itemId. What will happen when you send the request?/orders/{orderId}/items/{itemId} in Postman. You have a list of order IDs and item IDs. Which approach correctly tests all combinations using path parameters?Pass the test and this pattern moves unknown