
Mastering Postman: From CRUD to Automation and Beyond
Madhuka Malshan / June 4, 2025
๐ Introduction to Postman
If you're working with APIs, Postman is your go-to tool. It allows developers to test, document, and automate RESTful APIs with ease. Whether you're building a simple CRUD API or testing complex workflows, Postman simplifies every step.
Letโs dive in and unlock the true power of Postman!
๐ CRUD Operations in Postman
โ Create (POST)
Used to send data to the server to create a new resource.
POST /api/users
Body (raw/JSON):
{
"name": "Madhuka",
"email": "madhuka@mail.com"
}
๐ฅ Read (GET)
Used to retrieve information.
GET /api/users
โ๏ธ Update (PUT / PATCH)
Update an existing resource.
PUT /api/users/1
Body:
{
"email": "updated@mail.com"
}
โ Delete (DELETE)
Remove a resource.
DELETE /api/users/1
๐ Environment Variables
Environment variables help you switch between different setups (like local, staging, production) without rewriting URLs or tokens.
๐ง Example:
{{base_url}}โhttp://localhost:8080{{token}}โBearer your_jwt_token_here
You can set these in:
โ๏ธ Environment Settings โ Manage Environments
Then use {{base_url}}/api/users in your requests.
๐ Request Body & Parameters
Postman supports multiple body types:
raw(JSON, XML, Text)form-data(for file uploads)x-www-form-urlencoded
And also allows you to add:
- Query Params:
/users?page=1 - Path Variables:
/users/:id
๐ก Tip: Use Params tab for query parameters and Pre-request Script for dynamic body construction.
๐ฌ Headers & Authentication
Use the Headers tab to add custom headers like:
Authorization: Bearer tokenContent-Type: application/json
Also supports:
- Basic Auth
- Bearer Tokens
- API Key
- OAuth 2.0
๐ Status Codes
Postman will show response codes, time, and size. Key HTTP Status Codes:
200 OK: Request succeeded201 Created: Resource created400 Bad Request: Client error401 Unauthorized: Auth required404 Not Found: Resource not found500 Internal Server Error: Server crash
โ๏ธ Automation with Tests
Postman supports JavaScript-based test automation.
pm.test("Status is 200", function () {
pm.response.to.have.status(200);
});
pm.test("Content-Type is JSON", function () {
pm.response.to.have.header("Content-Type");
});
You can write test cases to validate responses, headers, values, response times, etc.
๐ Pre-request Script & Chaining Requests
Use Pre-request Scripts to set values before sending a request.
pm.environment.set("userId", "1234");
You can also chain requests by storing data in variables:
let response = pm.response.json();
pm.environment.set("userId", response.id);
Then use {{userId}} in the next request.
๐ฆ Collections & Folders
Group your requests into collections for better organization.
- Folders group requests logically (e.g., Auth, User, Orders)
- Collections can be exported and shared across teams
๐ Collection Runner
Run an entire collection of requests sequentially with predefined data.
You can import a CSV or JSON file to test with multiple sets of data (Data-Driven Testing).
๐ Console for Debugging
Use the Postman Console (View โ Show Postman Console or Ctrl + Alt + C) to:
- Log variables
- Debug pre-request/test scripts
- Inspect full request & response
console.log("Token is: ", pm.environment.get("token"));
๐ก Useful Tips
โ
Use variables to avoid repetition
โ
Save frequent requests as collections
โ
Write tests for expected outcomes
โ
Use pm.environment and pm.globals wisely
โ
Share environment and collections with your team
๐ซ Common Mistakes
โ Forgetting to set Content-Type
โ Mixing path and query parameters
โ Not saving updated environments
โ Overwriting global variables accidentally
๐ง Quick Quiz
- What is the difference between PUT and PATCH?
- Where do you set authentication tokens in Postman?
- How can you chain data between requests?
- What does the Postman Console help you with?
๐ FAQ
Q: Can Postman be used with GraphQL? A: Yes! Postman has built-in support for GraphQL requests.
Q: Can I export my collections? A: Absolutely. You can export and import collections, environments, and more.
Q: Can I use Postman for automated testing? A: Yes โ use tests, the Collection Runner, and Newman (CLI tool) for automation.
๐ฎ Whatโs Next?
- ๐งช Newman: Run Postman tests via CLI in CI/CD
- ๐ OAuth 2.0: Setup advanced authentication flows
- ๐ Mock Servers: Simulate API responses
- ๐ Monitors: Schedule collection runs and monitor performance