Overview
This guide explains the generic workflow for interacting with your network camera’s CGI interface using Postman. The same method applies to any CGI‑based configuration – audio, video, network, events, PTZ, etc.
If you are looking for a specific example (e.g., disabling audio or changing video resolution), please refer to the related Example articles in this CGI section. This guide focuses on the reusable method.
1. Prerequisites
- Postman installed – Download here
- Network camera IP address, username, password (example: 192.168.1.120, admin, 12345)
- Your camera must support the following CGI endpoints:
- Get configuration – GET /action/get?subject=XXX&user=admin&pwd=12345
- Set configuration – POST /action/set?subject=XXX&user=admin&pwd=12345 with XML body
2. The Generic Workflow (Step-by-Step)
Step 1 – Get Current Configuration (GET)
Always start by retrieving the current values. This gives you the correct XML structure and the existing parameters.
- In Postman, create a new request.
- Set method to GET.
- Enter the URL with your camera’s IP, username, and password: http://192.168.1.120/action/get?subject=audioenc&user=admin&pwd=12345 (replace audioenc with the subject you need, e.g., videoenc, network, event)
- Click Send.
- Copy the entire XML response. It will look like:
<?xml version="1.0" encoding="utf-8"?>
<response>
<audioenc ver="2.0">
<active>1</active>
<codec>0</codec>
<sample>8000</sample>
<bitwidth>16</bitwidth>
<bitrate>16000</bitrate>
<channel>0</channel>
<input>1</input>
</audioenc>
Step 2 – Prepare the SET Request (POST)
- Create a new request in Postman.
- Set method to POST.
- Enter the SET URL (authentication in URL): http://192.168.1.120/action/set?subject=audioenc&user=admin&pwd=12345.
- Go to the Headers tab and add: Content-Type: application/xml
- Go to the Body tab → select raw → choose XML from the dropdown.
- Build the XML payload using this template:
<?xml version="1.0" encoding="utf-8"?>
<request>
<audioenc>
<active>0</active>
<codec>0</codec>
<sample>8000</sample>
<bitwidth>16</bitwidth>
<bitrate>16000</bitrate>
<channel>0</channel>
<input>1</input>
</audioenc>
</request>
Critical rules:
- Root element must be <request>.
- The inner tag (e.g., <audioenc>) must exactly match the one returned by GET (could be <audience>, <videoenc>, etc.).
- Include all child parameters – do not send only the field you want to change.
- Modify only the values you need (e.g., change <active>1</active> to <active>0</active>).
Step 3 – Send the POST Request
Click Send. A successful response typically returns:
If you receive an error, see the Error Handling section below.
Step 4 – Verify the Change
Repeat the GET request (Step 1) and confirm that the modified value has been applied.
3. Error Handling
HTTP Status / Response | Meaning | Likely Cause & Solution |
200: Succeed to Set. | Success | - |
400: Error to Request. | Bad request | XML malformed, missing tags, or incorrect tag names. Check that you used the exact structure from GET. |
403: No authorized. | Authentication failed | Wrong username/password . If camera uses Digest Auth, set Postman’s Authorization type to “Digest Auth”. |
500: Failed to Set. | Internal error | One or more parameter values are invalid (out of range, unsupported combination). Compare with the GET response values.
|
4. Best Practices with Postman
Save Requests as a Collection
- After configuring a GET or POST request, click Save.
- Create a new Collection (e.g., Camera CGI) and save both requests inside it.
- You can now reuse them anytime without re‑entering URLs or XML bodies.
Use Environment Variables
Avoid hardcoding IP, username, and password in every request:
1. Click the Environment quick look icon (eye icon) → Edit → Add.
2. Create variables:
- {{baseUrl}} = http://192.168.1.120
- {{user}} = admin
- {{pwd}} = 12345
3. In your requests, use:
- GET: {{baseUrl}}/action/get?subject=audioenc&user={{user}}&pwd={{pwd}}
- POST: {{baseUrl}}/action/set?subject=audioenc&user={{user}}&pwd={{pwd}}
Now you can switch cameras by changing the environment variables.
5. Learn More
Now that you understand the generic method, explore the example articles in this CGI section:
- Example: Audio Configuration (Enable/Disable, Codec, Sample Rate)-->Updating
- …and more.
Each example follows the exact same workflow, only the XML content changes.