Master Postman: From Installation to Advanced API Testing Features
This comprehensive guide walks you through Postman's installation, interface navigation, basic request types, response parsing, collection management, batch execution, logging, assertions, variables, pre‑request scripts, request chaining, and common value extraction, providing practical steps and code examples for effective API testing.
Postman is a powerful HTTP API debugging and testing tool that is easy to use for developers and testers.
The tool offers a wide range of features, which are grouped into three dimensions: basic functions, convenient fast‑track functions, and advanced functions.
Basic functions include common request types, response data parsing, collection management, batch execution, logging, assertions, variables, pre‑request scripts, request chaining, and common return value extraction.
Convenient fast‑track functions cover quick parameter entry, header filling, request creation, collection authentication inheritance, batch assertions, and search‑replace.
Advanced functions comprise file parameterization, test report generation, sending requests from code, documentation generation, mock services, monitoring, workspace usage, code sync and branch management, database connections, and APIs.
1. Postman Installation
Since 2018 Postman no longer supports a browser version, you must download the client. For Windows, download the latest version from the official website, run the installer, and log in or skip login for personal use.
2. Interface Navigation
The main interface elements are illustrated in the following diagram.
3. Sending the First Request
Create a new request, enter the URL (e.g., http://www.weather.com.cn/data/sk/101010100.html), and click Send to view the JSON response.
4. Basic Request Types
4.1 Query Parameters
Query parameters appear after the ? in a URL (e.g., number=13012345678). In Postman, set the method to GET and enter the full URL or use the Params tab.
4.2 Form‑Encoded Requests
When the request header Content‑Type is application/x-www-form-urlencoded, fill in the method POST, URL, header, and body fields such as
username=13088888888&password=123456&verify_code=8888.
4.3 File Upload (multipart/form‑data)
POST http://localhost/index.php/home/Uploadify/imageUp/savepath/head_pic/pictitle/banner/dir/images.html HTTP/1.1
Content-Type: multipart/form-data
file=a1.jpgSet the method to POST, choose form‑data as the body type, and select File for the file field.
4.4 JSON Body
POST http://xxx/api/sys/login HTTP/1.1
Content-Type: application/json;charset=UTF-8
{"account":"root","password":"123456"}Choose raw → JSON as the body type and fill in the JSON payload.
5. Response Data Parsing
Postman displays the status line, response headers (including cookies), and response body. The body can be viewed in Pretty (formatted), Raw (original), or Preview (HTML rendering) modes.
6. Collection Management
Create a collection to group related requests, add folders for modules, and add individual requests. Collections enable batch execution, mock servers, documentation, and more.
7. Batch Execution
Select a collection, click the run button to open the Collection Runner, and execute all selected requests together.
8. Logging
Use console.log() in Pre‑request Script or Tests to output logs. View logs via the Postman console or the lower‑left icon, with search and level filtering features.
9. Assertions
Write JavaScript assertions in the Tests tab, such as status code, response header, body content, JSON value checks, and response time. Postman provides built‑in snippets for common assertions.
pm.test("Status code is 200", function () {
pm.response.to.have.status(200);
}); pm.test("Content-Type is present", function () {
pm.response.to.have.header("Content-Type");
}); pm.test("Body matches string", function () {
pm.expect(pm.response.text()).to.include("string_you_want_to_search");
});10. Variables (Global, Environment, Collection)
Variables store reusable values. Global variables are available everywhere, collection variables are scoped to a collection, and environment variables apply to a selected environment. Use {{variable_name}} in request fields or JavaScript getters such as pm.environment.get('var').
11. Pre‑request Scripts
Pre‑request scripts run before a request is sent, allowing tasks like generating random numbers or encrypting passwords.
12. Request Chaining
Extract a value from a previous response, save it as a variable, and use it in a subsequent request to create dependent workflows.
var jsonData = pm.response.json();
var url = jsonData.url;
pm.globals.set('uploadedUrl', url);13. Common Return Value Extraction
Use JavaScript to navigate JSON structures, e.g., jsonData.data.user_id for nested fields, jsonData.data.roles.points[1] for array elements, or jsonData.data.rows.slice(-1)[0] for the last item.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
