Back to posts
Mastering Postman: From CRUD to Automation and Beyond

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 token
  • Content-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 succeeded
  • 201 Created: Resource created
  • 400 Bad Request: Client error
  • 401 Unauthorized: Auth required
  • 404 Not Found: Resource not found
  • 500 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

  1. What is the difference between PUT and PATCH?
  2. Where do you set authentication tokens in Postman?
  3. How can you chain data between requests?
  4. 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