logo
In-app Chat
Powered Byspreading
On this page

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 and ServerSecret, that are required to call an API operation.
Warning
  • 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

  1. Click Import to import the two JSON files that are extracted from the Postman collection package into Postman./Pics/ZIM/postman/postman_import.png

  2. In the upper-right corner of Postman, select ZIM as the environment./Pics/ZIM/postman/postman_env.png

  3. 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./Pics/ZIM/postman/postman_setenv.png

3. Debug API operations

This section describes how to use Postman to debug server API operations. Several operations are used in the example.

Note

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.

  1. In the left-side navigation pane, click Collections. Then, select QueryUserOnlineState, and set parameters as needed. For more information, see QueryUserOnlineState./Pics/ZIM/postman/postman_QueryUserOnlineState.png

  2. 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 not 0, modify the request parameters based on the error message returned in the response and send a request again. /Pics/ZIM/postman/postman_QueryUserOnlineState_response.png

3.2 SendRoomMessage

You can call this operation to send a message to a room.

  1. In the left-side navigation pane, click Collections. Then, select SendRoomMessage, and set parameters as needed. For more information, see SendRoomMessage./Pics/ZIM/postman/postman_SendRoomMessage.png

  2. 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 not 0, modify the request parameters based on the error message returned in the response and send a request again. /Pics/ZIM/postman/postman_SendRoomMessage_response.png

3.3 KickoutRoomUser

You can call this operation to remove a user from the room.

  1. In the left-side navigation pane, click Collections. Then, select KickoutRoomUser, and set parameters as needed. For more information, see KickoutRoomUser./Pics/ZIM/postman/postman_KickoutUser.png

  2. 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 not 0, modify the request parameters based on the error message returned in the response and send a request again. /Pics/ZIM/postman/postman_KickoutUser_response.png

Previous

Return codes