API testing with Postman
Last updated:2024-10-17 15:02
This document describes how to perform server API testing by using Postman.
As an API commissioning tool, Postman enables you to visually and conveniently test server APIs on graphical user interfaces (GUIs).
To help you test the cloud recording server API, ZEGOCLOUD provides the corresponding Postman Collection, which has the pre-defined request parameters of each API. In this manner, you can perform the commissioning test after they import the parameters and modify the parameter values.
1. Prerequisites
- Click Import to import the files obtained when collection is decompressed.
- Set the environment to cloudrecord.
- Open the cloudrecord environment, set AppID and ServerSecret obtained in the Prerequisites steps in CURRENT VALUE of the corresponding environment variables, and save the settings.
4. Testing APIs
This chapter uses three APIs as an example to show how to test the server API by using Postman.
The collection provided by ZEGOCLOUD can use environment variables and preset scripts to automatically specify public parameters. You can view the preset scripts in the following figure, which can be used for reference when you develop the server.
4.1 Start recording
This API is used to start the recording task and implement single-stream recording, mixed-stream recording, and screenshot capture depending on the passed-in parameters.
Four groups of request parameters for this API are preset in the collection provided by ZEGOCLOUD, which correspond to single-stream recording, mixed-stream recording (grid layout), mixed-stream recording (customized layout), and screenshot capture. Multiple recording tasks can be started at the same time in the same room.
4.1.1 Single-stream recording
In single-stream recording mode, each audio or video stream and whiteboard in the room are respectively recorded. The corresponding media file is generated for each audio or video stream, and a video file is generated for all whiteboards.
- Choose StartRecord_Single in Collections and view the Body tab.
- RoomId: The ID of the recording room.
- RecordInputParams: The input parameters of the recording task. The preset parameters in the request indicate that only the audio of stream 1 and stream 2 is recorded, and a media file is generated for each stream. Other optional parameters retain the default values.
- RecordOutputParams: The output parameters of the recording task. The preset parameters in the request indicate that MP4 media files are output to the test folder of the storage service.
- StorageParams: The storage configuration of the recording task.
Modify the request parameters as required and perform the commissioning test. For more information about the parameters, see Start recording.
- Click Send to check the response. If the error code in the response is not 0, modify the request based on the error description of the response and send the request again. Ensure that TaskId returned in the response is saved.
4.1.2 Mixed-stream recording
In mixed-stream recording mode, all audio or video streams and whiteboards in a room are recorded in a mixed manner to an audio and video file. Mixed-stream recording supports multiple image layout modes. For more information, see Set mixed-stream layout.
Two groups of parameters for split layout and customized layout are preset in the collection provided by ZEGOCLOUD.
Grid layout
- Choose StartRecord_Mixed_Split in Collections and view the Body tab.
- RoomId: The ID of the recording room.
- RecordInputParams: The input parameters of the recording task.
- RecordMode and StreamType: Indicate that the recording mode is set to mixed-stream recording, and the recording content is set to audio and video file.
- FillBlank: Specifies the image filling method when the stream recording is interrupted. If it is not specified, the default configuration is used.
- FillFrame: Specifies the image filling method when the camera for stream recording is turned off. If it is not specified, the default configuration is used.
- MaxIdleTime and MaxRecordTime: Indicate the time configuration related to the automatic ending of recording tasks. If it is not specified, the default configuration is used.
- MixConfig: The configuration related to mixed streams. The preset parameters in the request indicate that the split layout is used for images during mixed-stream recording and specify the output stream names and audio and video parameters. For more information, see Grid layout in "Set mixed-stream layout".
- RecordOutputParams: The output parameters of the recording task. The preset values in the request indicate that MP4 media files are output to the test folder of the storage service.
- StorageParams: The storage configuration of the recording task.
Modify the request parameters as required and perform the commissioning test. For more information about the parameters, see Start recording.
- Click Send to check the response. If the error code in the response is not 0, modify the request based on the error description of the response and send the request again. Ensure that TaskID returned in the response is saved.
Customized layout
- Choose StartRecord_Mixed_Custom in Collections and view the Body tab.
- RoomId: The ID of the recording room.
- RecordInputParams: The input parameters of the recording task.
- RecordMode and StreamType: Indicate that the recording mode is set to mixed-stream recording, and the recording content is set to audio and video file.
- HasWhiteboard and Whiteboard: Specify the related parameters for whiteboard recording. They are required for whiteboard recording.
- MixConfig: The configuration related to mixed streams. The preset parameters in the request indicate that the customized layout is used for images during mixed-stream recording and specify the output stream names and audio and video parameters. For customized layout, the layout mode is specified by the MixInputList parameter. For more information, see Customize the video layout in "Set mixed-stream layout".
- RecordOutputParams: The output parameters of the recording task. The preset values in the request indicate that MP4 media files are output to the test folder of the storage service.
- StorageParams: The storage configuration of the recording task.
Modify the request parameters as required and perform the commissioning test. For more information about the parameters, see Start recording.
- Click Send to check the response. If the error code in the response is not 0, modify the request based on the error description of the response and send the request again. Ensure that TaskId returned in the response is saved.
4.1.3 Capture screenshots
When you call the Start recording API, you can start a screenshot capture task by setting RecordMode to 1 and OutputFileFormat to jpg. You can set SnapshotInterval to specify the screenshot interval. For more information, see Capture screenshots.
- Choose StartRecord_Snapshot in Collections and view the Body tab.
Modify the request parameters as required and perform the commissioning test. For more information about the parameters, see Start recording.
- Click Send to check the response. If the error code in the response is not 0, modify the request based on the error description of the response and send the request again. Ensure that TaskId returned in the response is saved.
4.2 Stop recording
This API is used to stop an ongoing recording task.
- Choose Stop recording in Collections and replace the value of TaskId in the request parameter with the value of TaskId returned when the StartRecord API is called.
- Click Send to check the response. If the error code in the response is not 0, modify the request based on the error description of the response and send the request again.
4.3 Query recording status
This API is used to query the status of a recording task.
- Choose Query recording status in Collections and replace the value of TaskId in the request parameter with the value of TaskId returned when the StartRecord API is called.
- Click Send to check the response. If the error code in the response is not 0, modify the request based on the error description of the response and send the request again. For more information about the return parameters, see Query recording status.