Documentation
Server_APIs_v2 Server APIs v2
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Server APIs v2
  • API testing
  • API testing with Postman

API testing with Postman

Last updated:2022-03-22 13:07

This document describes how to use the Postman tool for Server API testing.

Postman is an API testing tool, which makes it easy to ensure your APIs are reliable and ready to launch.

For your convenience, ZEGO provides the Postman Collection and predefines request parameters for each API. When the Collection is imported, you can start testing the RTC Server APIs after changing the parameter values.

1 Prerequistes

  • Download Postman.
  • Download and extract the RTC Postman Collection package.
  • Log in to the ZEGO Admin Console and obtain the AppId and ServerSecret.

The UI of Postman varies on different platforms. This document uses Postman on macOS as an example.

2 Import and configure the Postman Collection

  1. Click the Import button, and upload the extracted two Postman Collection files.

/Pics/server_v2/postman/import.png

  1. Select RTC in the drop-down box to set the environment.

/Pics/server_v2/postman/set_env.png

  1. Select Environments > RTC, in the CURRENT VALUE column, fill in the AppID and ServerSecret you get in the previous step, and click Save.

/Pics/server_v2/postman/set_env_value.png

If the AppID uses the testing environment (for details, see the description of the IsTest parameter in Accessing Server APIs - Public parameters), you need to change the IsTest value (the last parameter in the figure above) to true.

4 API testing

The following 3 APIs are used as examples to describe how to use Postman for API testing.

The Postman Collection provided by ZEGO automatically fills in public parameters with environment variables and pre-scripts. You can see the pre-script in the location shown below and use it as a reference when developing the server API.

/Pics/server_v2/postman/pre_script.png

4.1 Send a broadcast message

This API is used for sending broadcast messages in a room.

You need to log in to a room before making the API call.

You can refer to the Quick start to build your own app and log in to a room.

  1. Select Collections > SendBroadcastMessage, refer to the Send a broadcast message to modify the parameters accordingly.

Parameter values wrapped in double curly braces are environment variables and do not need to be modified.

/Pics/server_v2/postman/send_broadcast_message.png

  1. Click Send, and check the returned message. If the returned error code is not 0, then modify your request and send it again.

/Pics/server_v2/postman/send_broadcast_message_rsp.png

4.2 Kick a user out of a room

This API is used for kicking one or more specified users out of a room, and all the streaming operations of the target user will stop.

You need to log in to a room before making the API call.

You can refer to the Quick start to build your own app and log in to a room.

  1. Select Collections > KickoutUser, refer to the Kick a user out of a room to modify the parameter values accordingly.

UserId[] is the ID of the target user that you want to kick out. You can kick out of 1-5 users at a time, for more, check the description of this parameter.

/Pics/server_v2/postman/kickout_user.png

  1. Click Send, and check the returned message. If the returned error code is not 0, then modify your request and send it again.

/Pics/server_v2/postman/kickout_user_rsp.png

4.3 Start stream mixing

This API is used for starting or updating a stream mixing task.

Before using this interface for the first time, you need to contact ZEGO technical support to activate it.

  1. Select Collections > StartMix, and refer to the Start stream mixing to modify the Body parameters accordingly.

/Pics/server_v2/postman/start_mix.png

  1. Click Send, and check the returned message. If the returned error code is not 0, then modify your request and send it again.

/Pics/server_v2/postman/start_mix_rsp.png

Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code