Debugging guide of server API operations
This topic describes how to use Postman to debug server API operations.
Postman allows you to debug server API operations on a GUI in a convenient and visualized manner.
ZEGO Instant Messaging (ZIM) provides a Postman collection to help you debug server API operations. In the Postman collection, the request parameters of each operation are predefined. After you import the Postman collection, you need to only modify the parameter values to debug server API operations.
1. Prerequisites
- Postman is downloaded and installed.
- The Postman collection package of the server API of ZIM is downloaded and decompressed.
- You have logged in to the ZEGO console and obtained the parameters, such as
AppId
andServerSecret
, that are required to call an API operation.
- The client UI of the Postman plug-in varies based on the platform. In this example, the Postman plug-in of the macOS operating system is used.
- The provided Postman collection is only for debugging and does not contain all operations of the server API.
2. Import and configure the Postman collection
-
Click Import to import the two JSON files that are extracted from the Postman collection package into Postman.
-
In the upper-right corner of Postman, select ZIM as the environment.
-
In the left-side navigation pane, click Environments. Then, select the ZIM environment. In the CURRENT VALUE column of the corresponding environment variable, enter the application ID and the server secret that are obtained in the 1. Prerequisites section. After you configure the settings, click Save.
3. Debug API operations
This section describes how to use Postman to debug server API operations. Several operations are used in the example.
The double braces {{xxxx}}
in the VALUE column of some parameters indicate that the parameter values are environment variables. You do not need to modify the parameter values.
3.1 QueryUserOnlineState
You can call this operation to query the online status of a user.
-
In the left-side navigation pane, click Collections. Then, select QueryUserOnlineState, and set parameters as needed. For more information, see QueryUserOnlineState.
-
Click Send and view the response in the lower part of the page. If the return value of the
Code
parameter in the response is not0
, modify the request parameters based on the error message returned in the response and send a request again.
3.2 SendRoomMessage
You can call this operation to send a message to a room.
-
In the left-side navigation pane, click Collections. Then, select SendRoomMessage, and set parameters as needed. For more information, see SendRoomMessage.
-
Click Send and view the response in the lower part of the page. If the return value of the
Code
parameter in the response is not0
, modify the request parameters based on the error message returned in the response and send a request again.
3.3 KickoutRoomUser
You can call this operation to remove a user from the room.
-
In the left-side navigation pane, click Collections. Then, select KickoutRoomUser, and set parameters as needed. For more information, see KickoutRoomUser.
-
Click Send and view the response in the lower part of the page. If the return value of the
Code
parameter in the response is not0
, modify the request parameters based on the error message returned in the response and send a request again.