Example requests and responses help you understand how an API works by showing what to send and what to expect back.
Example requests and responses in Postman
Introduction
Syntax
Postman
GET /api/users HTTP/1.1 Host: example.com Response: HTTP/1.1 200 OK Content-Type: application/json { "users": [ {"id": 1, "name": "Alice"}, {"id": 2, "name": "Bob"} ] }
The request shows the method (GET), the URL path (/api/users), and headers.
The response shows the status code (200 OK), headers, and the JSON data returned.
Examples
Postman
POST /api/login HTTP/1.1 Host: example.com Content-Type: application/json { "username": "user1", "password": "pass123" } Response: HTTP/1.1 200 OK Content-Type: application/json { "token": "abc123xyz" }
Postman
GET /api/products/5 HTTP/1.1 Host: example.com Response: HTTP/1.1 404 Not Found Content-Type: application/json { "error": "Product not found" }
Sample Program
This is a simple example of a GET request to fetch a list of books and the expected JSON response with book details.
Postman
GET /api/books HTTP/1.1 Host: example.com Response: HTTP/1.1 200 OK Content-Type: application/json { "books": [ {"id": 101, "title": "Learn Testing"}, {"id": 102, "title": "API Basics"} ] }
Important Notes
Always check the status code to know if the request was successful.
Use clear and simple example data to make understanding easier.
Include both request and response to show the full interaction.
Summary
Example requests and responses show how to use an API step-by-step.
They help you test and understand API behavior.
Clear examples make teamwork and learning faster.
Practice
1. What is the main purpose of example requests and responses in Postman?
easy
Solution
Step 1: Understand the role of example requests
Example requests demonstrate how to call an API with real data.Step 2: Understand the role of example responses
Example responses show what the API returns for those requests.Final Answer:
To show how to use an API step-by-step -> Option DQuick Check:
Example requests + responses = API usage guide [OK]
Hint: Examples explain API use clearly and simply [OK]
Common Mistakes:
- Thinking examples create APIs
- Confusing examples with coding
- Assuming examples design UI
2. Which of the following is the correct way to add an example response in Postman?
easy
Solution
Step 1: Identify how to save example responses
After sending a request, Postman allows saving the response as an example.Step 2: Confirm the correct action
Clicking 'Save Response' saves the current response as an example for future reference.Final Answer:
Click 'Save Response' after sending a request -> Option BQuick Check:
Save response = example response [OK]
Hint: Save response after request to create example [OK]
Common Mistakes:
- Trying to add examples by editing URL
- Confusing Tests tab with examples
- Changing method does not save examples
3. Given this example request in Postman:
And this example response:
What does the response show?
{
"name": "Alice",
"age": 30
}And this example response:
{
"id": 101,
"name": "Alice",
"age": 30
}What does the response show?
medium
Solution
Step 1: Compare request and response fields
The request sends name and age; the response adds an id field.Step 2: Understand the meaning of added id
The id is usually a unique identifier assigned by the API to the new user.Final Answer:
The API returns the user data with a new ID -> Option CQuick Check:
Response adds id to request data [OK]
Hint: Response adds new info like ID to request data [OK]
Common Mistakes:
- Assuming error without error message
- Ignoring added id field
- Thinking age is removed
4. You saved an example response in Postman, but it shows outdated data. What is the best way to fix this?
medium
Solution
Step 1: Identify how to update example responses
Example responses reflect saved data; to update, you must get fresh data from the API.Step 2: Choose the correct update method
Sending the request again gets current data; saving it updates the example correctly.Final Answer:
Send the request again and save the new response as example -> Option AQuick Check:
Refresh example by resending and saving response [OK]
Hint: Resend request and save response to update example [OK]
Common Mistakes:
- Editing example manually can cause errors
- Deleting request is unnecessary
- Changing URL changes API, not example
5. You want to create an example request and response in Postman to show how to update a user's email. Which steps should you follow?
hard
Solution
Step 1: Use the correct HTTP method for update
PUT is the standard method to update existing data like email.Step 2: Save the response after sending the update request
Saving the response as example shows the API's reply to the update.Final Answer:
Send a PUT request with new email, then save the response as example -> Option AQuick Check:
Update with PUT + save response example [OK]
Hint: Use PUT for update, then save response example [OK]
Common Mistakes:
- Using GET instead of PUT for update
- Editing Tests tab does not create examples
- Deleting user is unrelated
Recommended
Ready to prove it?
Pass the test and this pattern moves unknown
10 questions ~5 mineasy hard
