Share
Explore

10 graduated exercises that teach students how to use Postman with Express route endpoints

megaphone

Postman is a web application development tool for testing API URLs (URIs) and scripting integrations, valuable for developers, students, and testers.

Installing Postman is straightforward and enables fast API inspection, validation, and debugging.

Installing Postman Today

Go to the official Postman download page, select the installer for the operating system (Windows, macOS, Linux), and download the app.
For Windows, run the downloaded .exe file and follow the prompts to install.youtube+1
On macOS, open the .zip or .dmg file and drag the Postman app to Applications.
For Linux, use Snap with sudo snap install postman, or download and extract from the official site. Optionally, create a desktop entry for easy launching.
After installation, launch Postman, create or sign in to a Postman account (required for full functionality), and optionally set up a workspace to organize requests.youtube+1
Postman also offers a web-based version if you prefer not to install software locally.

Postman URI Test Purposes

Validates that API endpoints (URIs) return expected responses, status codes, and data formats via different HTTP methods (GET, POST, PUT, DELETE).
Allows testing of authentication, headers, payloads, and query parameters for API requests.youtube
Facilitates writing tests in JavaScript to automate checks for response status, data, and error handling, supporting contract, unit, and integration testing.
Supports organizing requests into collections, running sequences of tests, and maintaining environment variables for multiple setups (dev, QA, production).
Enables debugging of APIs during development and documents API behavior for team collaboration.

Common Use Cases in Education and Development

Streamlines learning about RESTful APIs, HTTP methods, and client-server communication.youtube
Helps QA engineers and developers rapidly find bugs and regressions in evolving APIs.
Supports demoing, sharing, and collaborating on API requests via collections and environments.
Automates repetitive checks or regression tests with scripts and the collection runner.
Used in curriculum at many institutions for hands-on API practice.
Postman is essential for anyone working with APIs, offering both manual URI testing and automated validation in collaborative, repeatable workflows.
Add to follow-upCheck sources

info

Lab Learning Path:


Lab 1: Basic GET (no parameters) - simplest starting point
Lab 2: Query parameters in URLs - form data with GET
Lab 3: Route parameters - resource identification
Lab 4: POST with form data - first mutation
Lab 5: POST with JSON - modern API approach
Lab 6: REST pattern - same URL, different methods
Lab 7: Validation - proper error handling
Lab 8: Complete CRUD - full lifecycle
Lab 9: Advanced search - complex filtering
Lab 10: E-commerce app - everything combined

Each Lab Includes:

Complete Express.js code - ready to copy/paste into VS Code
HTML pages with working forms - visual interface for testing
Step-by-step Postman instructions - how to test each endpoint
Multiple test scenarios - success and error cases
Clear explanations - what you're learning and why
Expected responses - know what to look for

Special Features:

Postman installation guide at the start
Mix of GET and POST throughout with clear distinctions
Query parameters and route parameters explained
Form data and JSON body examples
Validation and error handling patterns
Real-world scenarios (task manager, e-commerce, employee search)
Each exercise is completely self-contained and can run independently on different ports.
Students can follow along sequentially or jump to specific concepts they need to practice.

MADS 4012 - Postman & Express Route Endpoints

10 Graduated Lab Exercises

Getting Started: Download and Install Postman

Before beginning these exercises, you need to install Postman:
Download the version for your operating system (Windows, Mac, or Linux)
Install and launch Postman
You can create a free account or click "Skip and go to the app"
Create a new Collection called "MADS 4012 Labs" to organize your requests

Exercise 1: Basic GET Request (No Parameters)

Concept: Understanding the simplest possible GET endpoint

Step 1: Create the Express Application

Create a folder lab01-basic-get and create server.js:
const express = require('express');
const app = express();
const PORT = 3000;

// Basic GET endpoint
app.get('/welcome', (req, res) => {
res.json({
message: 'Welcome to MADS 4012!',
course: 'Full Stack Development',
timestamp: new Date()
});
});

app.listen(PORT, () => {
console.log(`Lab 1 server running on http://localhost:${PORT}`);
});

Step 2: Run the Server

cd lab01-basic-get
npm init -y
npm install express
node server.js

Step 3: Test with Postman

Open Postman
Click "New" → "HTTP Request"
Set Method: Select GET from dropdown
Enter URL: http://localhost:3000/welcome
Click "Send"

Expected Response

{
"message": "Welcome to MADS 4012!",
"course": "Full Stack Development",
"timestamp": "2024-10-02T14:30:00.000Z"
}

What You Learned

GET requests retrieve data without modifying anything
No parameters needed for simple data retrieval
Status code 200 means success
Response time shows server performance

Save Your Request

Click "Save" button
Name it "Lab 1 - Basic Welcome"
Add to your "MADS 4012 Labs" collection

Exercise 2: GET with Query Parameters

Concept: Passing data through URL query strings (form data in GET requests)

Note the use of express static middleware to serve up static content.
This is also how you get images to serve up

Step 1: Create the Application

Create folder lab02-query-params and create server.js:
const express = require('express');
const app = express();
const PORT = 3001;

app.use(express.static('public'));

// GET endpoint with query parameters
app.get('/greet', (req, res) => {
const firstName = req.query.firstName || 'Guest';
const lastName = req.query.lastName || '';
const age = req.query.age;
res.json({
greeting: `Hello, ${firstName} ${lastName}!`,
message: age ? `You are ${age} years old.` : 'Age not provided',
receivedParams: req.query
});
});

app.listen(PORT, () => {
console.log(`Lab 2 server running on http://localhost:${PORT}`);
});

Step 2: Create the HTML Form

Create folder public and create public/index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Lab 2 - Query Parameters</title>
<style>
body { font-family: Arial; max-width: 500px; margin: 50px auto; padding: 20px; }
input, button { display: block; width: 100%; margin: 10px 0; padding: 10px; }
button { background: #007bff; color: white; border: none; cursor: pointer; }
</style>
</head>
<body>
<h1>Greeting Form (GET Method)</h1>
<form action="/greet" method="GET">
<input type="text" name="firstName" placeholder="First Name" required>
<input type="text" name="lastName" placeholder="Last Name">
<input type="number" name="age" placeholder="Age">
<button type="submit">Submit with GET</button>
</form>
<p><strong>Notice:</strong> After submitting, look at the URL in your browser!</p>
</body>
</html>

Step 3: Test with Postman

Test 1: No Parameters
Method: GET
URL: http://localhost:3001/greet
Click "Send"
Test 2: With Parameters
Method: GET
URL: http://localhost:3001/greet?firstName=John&lastName=Doe&age=25
Click "Send"
Test 3: Using Params Tab (Cleaner way!)
Method: GET
URL: http://localhost:3001/greet
Click "Params" tab
Add Key-Value pairs:
firstName = Sarah
lastName = Smith
age = 30
Notice how Postman builds the URL automatically!
Click "Send"

What You Learned

Query parameters appear after ? in the URL
Multiple parameters separated by &
Form data sent via GET becomes visible in URL {url re writing}
Use req.query to read query parameters in Express
Postman's Params tab makes testing easier

Browser Test

Open browser to http://localhost:3001
Fill out the form and submit
Observe the URL changes with query parameters
Data is visible in the browser address bar

Exercise 3: GET with Route Parameters

Concept: URL parameters as part of the path (not query string)

Step 1: Create the Application

Create folder lab03-route-params and create server.js:
const express = require('express');
const app = express();
const PORT = 3002;

app.use(express.static('public'));

// Sample data
const students = {
101: { id: 101, name: 'Alice Johnson', major: 'Computer Science', gpa: 3.8 },
102: { id: 102, name: 'Bob Smith', major: 'Information Systems', gpa: 3.5 },
103: { id: 103, name: 'Carol White', major: 'Data Science', gpa: 3.9 }
};

// Route parameter endpoint
app.get('/students/:studentId', (req, res) => {
const studentId = req.params.studentId;
const student = students[studentId];
if (student) {
res.json({
success: true,
data: student
});
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.