Master API Testing with Postman: Real‑World Baidu, WeChat & Radio Cases

Learn how to use Postman for practical API testing by walking through three hands‑on examples—searching Baidu, interacting with WeChat’s public API, and triggering alerts on a specialized radio communication system—covering request setup, parameter handling, assertions, and common pitfalls.

FunTester
FunTester
FunTester
Master API Testing with Postman: Real‑World Baidu, WeChat & Radio Cases

Using Postman for API Testing

Postman is a Chrome‑based extension that provides a graphical interface for constructing HTTP requests, sending them, and validating responses. Effective API testing requires the provider’s documentation so that request URLs, headers, parameters, and authentication tokens can be reproduced accurately.

Prerequisites

API documentation that specifies endpoint URLs, required query parameters, request headers, and body formats.

Access to a browser’s network panel (e.g., Chrome DevTools) to capture real request headers and cookies when interacting with the target service.

For services that require authentication (e.g., access_token), a method to obtain a valid token before testing.

Example 1 – Baidu Search

Create a new collection in Postman (similar to creating a new project in an IDE).

Open the Baidu search page in a browser, perform a search, and open the Network tab. Copy the full request URL—including the query string—and all request headers (including User‑Agent, Cookie, etc.).

In Postman, create a new GET request, paste the copied URL, and add the captured headers under the Headers tab.

Click Send . The response body should match the browser’s result.

pm.test("Response contains expected keyword", function () {
    pm.response.to.have.body();
    pm.expect(pm.response.text()).to.include("bela");
});

This script uses Postman’s built‑in assertion language to automatically verify that the response contains the keyword bela.

Save the request in the collection for reuse. The collection can be exported or run in the Postman Collection Runner for batch testing.

Postman interface screenshot
Postman interface screenshot

Example 2 – WeChat Public API

Open the WeChat API documentation page and locate the endpoint you wish to test (e.g., sending a custom message).

Copy the endpoint URL and required parameters, noting the placeholder ACCESS_TOKEN in the query string.

Obtain a valid access_token by scanning the QR code shown in the documentation with a WeChat client. This token is the unique communication channel between your application and the public account.

In Postman, create a new request, replace ACCESS_TOKEN with the actual token, and fill in any additional parameters (e.g., touser, msgtype, content). Click Send . Verify that the API returns a success code (e.g., errcode:0 ) and that the message appears in the target WeChat public account.

WeChat API documentation
WeChat API documentation

Example 3 – Specialized Radio Communication (One‑Click Alarm)

Import the provided script file (which defines the alarm payload) into Postman via Import → File .

Change the HTTP method from GET to POST and set the request URL to the alarm service, e.g., http://192.168.xxx.xxx/api/alarm.

In the Body tab, select binary and attach the supplied file named 1 (the alarm audio or data payload).

Click Send . The service broadcasts the alarm to all terminals within the defined geographic area.

Important constraints:

Terminals must be registered and online; offline devices will not receive the alarm.

Terminals must have a successful location fix; devices without a known position are excluded.

Postman request configuration for radio alarm
Postman request configuration for radio alarm

Common Practices

Use Postman’s pm.test and pm.expect functions to automate validation of response content and status codes.

Organize related requests into collections; collections can be version‑controlled (e.g., stored in a Git repository) and executed repeatedly with the Collection Runner or Newman CLI.

When testing third‑party services that may block automated requests, copy the exact request headers and cookies from a real browser session to mimic a genuine user request.

By following these steps, testers can quickly set up, run, and maintain API tests for a variety of services using Postman.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

BackendAutomationWeChatAPI testingPostmanRadio communication
FunTester
Written by

FunTester

10k followers, 1k articles | completely useless

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.