This document shows how to create an internal app and use the APIs provided by Smart meeting room to create, update, query, and delete meeting rooms.
Expected result
The meeting room is displayed as follows:
Process overview
Prerequisite: Complete the App creation and configuration process.
Step 1: Obtain the app credential information, including the client ID and Client Secret.
Step 2: Request the API permissions for Smart meeting room.
Step 3: Obtain the app access credential by following Obtain the access token of an internal app. The access token is used to authenticate the caller when calling APIs.
Step 4: Call the meeting room APIs:
- Call the Server API Create a meeting room. The
result field returned by the API is the meeting room ID.
- With the meeting room ID, call the Server API Update meeting room information to update the meeting room information.
- Call the Server API Query the meeting room list to retrieve the list of meeting rooms.
- With the meeting room ID, call the Server API Query meeting room details to retrieve the details of a specific meeting room.
- With the meeting room ID, call the Server API Delete a meeting room to delete a meeting room.
Prerequisite
Complete the App creation and configuration process.
Step 1: Obtain the app credential
- Select the target app and go to the app details page. Click Basic information > Credentials and basic information.
- Obtain the client ID and Client Secret.
Step 2: Add API permissions
Click Development configuration > Manage permissions. In the permission search box, enter VideoConference.Conference.Write and VideoConference.Conference.Read respectively, and request the permissions.
Step 3: Obtain the access token
For details about the differences between Server API versions, see the comparison between the legacy and new APIs. The following endpoints all use Server APIs. For details about SDK downloads, see Server-side SDK downloads.
Using the client ID and Client Secret from Step 1, obtain the app access credential by following Obtain the access token of an internal app.
public void getAccessToken() throws Exception {
Config config = new Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkoauth2_1_0.Client client = new com.aliyun.dingtalkoauth2_1_0.Client(config);
GetAccessTokenRequest accessTokenRequest = new GetAccessTokenRequest()
.setAppKey("din*********hgn")
.setAppSecret("9G_O************mBkhgGIO");
GetAccessTokenResponse accessToken = client.getAccessToken(accessTokenRequest);
System.out.println(JSON.toJSONString(accessToken.getBody()));
}
Step 4: Call the meeting room APIs
-
Call the Server API Create a meeting room. The
result field returned by the API is the meeting room ID.
public void createMeetingRoom() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomHeaders createMeetingRoomHeaders = new com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomHeaders();
createMeetingRoomHeaders.xAcsDingtalkAccessToken = "acccessToken";
com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomRequest.CreateMeetingRoomRequestRoomLocation roomLocation = new com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomRequest.CreateMeetingRoomRequestRoomLocation()
.setTitle("***Test")
.setDesc("No. xx, xx Road, xx District, xx City");
com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomRequest createMeetingRoomRequest = new com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomRequest()
.setUnionId("E9CS6X*******eN7QiEiE")
.setRoomName("Test meeting room")
.setRoomCapacity(10)
.setRoomPicture("https://example/k/DingTalkImage1.png")
.setRoomStatus(0)
.setRoomLocation(roomLocation)
.setRoomLabelIds(java.util.Arrays.asList(
1L
))
.setIsvRoomId("dingTalk1001");
try {
CreateMeetingRoomResponse meetingRoomWithOptions = client.createMeetingRoomWithOptions(createMeetingRoomRequest, createMeetingRoomHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(meetingRoomWithOptions.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
}
}
-
With the meeting room ID, call the Server API Update meeting room information to update the meeting room information.
public void updateMeetingRooms() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomHeaders updateMeetingRoomHeaders = new com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomHeaders();
updateMeetingRoomHeaders.xAcsDingtalkAccessToken = "acccessToken";
com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomRequest.UpdateMeetingRoomRequestRoomLocation roomLocation = new com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomRequest.UpdateMeetingRoomRequestRoomLocation()
.setTitle("Alibaba***Tower A")
.setDesc("**District, **City");
com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomRequest updateMeetingRoomRequest = new com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomRequest()
.setUnionId("E9CS6X*******eN7QiEiE")
.setRoomId("9d5356997e44f******0ab267c05d6b3a14")
.setRoomName("Meeting room test")
.setRoomCapacity(10)
.setRoomPicture("https://example/k/DingTalkImage1.png")
.setRoomStatus(0)
.setRoomLocation(roomLocation)
.setRoomLabelIds(java.util.Arrays.asList(
1L
))
.setIsvRoomId("dingTalk1001");
try {
UpdateMeetingRoomResponse updateMeetingRoomResponse = client.updateMeetingRoomWithOptions(updateMeetingRoomRequest, updateMeetingRoomHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(updateMeetingRoomResponse.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
}
}
-
Call the Server API Query the meeting room list to retrieve the list of meeting rooms.
public void meetingRoomsList() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomListHeaders queryMeetingRoomListHeaders = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomListHeaders();
queryMeetingRoomListHeaders.xAcsDingtalkAccessToken = "acccessToken";
com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomListRequest queryMeetingRoomListRequest = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomListRequest()
.setMaxResults(20)
.setUnionId("E9CS6X*******eN7QiEiE");
try {
QueryMeetingRoomListResponse queryMeetingRoomListResponse = client.queryMeetingRoomListWithOptions(queryMeetingRoomListRequest, queryMeetingRoomListHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(queryMeetingRoomListResponse.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
}
}
-
With the meeting room ID, call the Server API Query meeting room details to retrieve the details of a specific meeting room.
public void meetingRoomsInfo() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomHeaders queryMeetingRoomHeaders = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomHeaders();
queryMeetingRoomHeaders.xAcsDingtalkAccessToken = "acccessToken";
com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomRequest queryMeetingRoomRequest = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomRequest()
.setUnionId("E9CS6X*******eN7QiEiE");
try {
QueryMeetingRoomResponse queryMeetingRoomResponse = client.queryMeetingRoomWithOptions("9d5356997e44f******0ab267c05d6b3a14", queryMeetingRoomRequest, queryMeetingRoomHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(queryMeetingRoomResponse.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
}
}
-
With the meeting room ID, call the Server API Delete a meeting room to delete a meeting room.
Note
Deleting a meeting room requires the Smart meeting room App Management permission.
public void deleteMeetingRoom() throws Exception {
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.protocol = "https";
config.regionId = "central";
com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomHeaders deleteMeetingRoomHeaders = new com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomHeaders();
deleteMeetingRoomHeaders.xAcsDingtalkAccessToken = "acccessToken";
com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomRequest deleteMeetingRoomRequest = new com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomRequest()
.setUnionId("E9CS6X*******eN7QiEiE");
try {
DeleteMeetingRoomResponse deleteMeetingRoomResponse = client.deleteMeetingRoomWithOptions("9d5356997e44f******0ab267c05d6b3a14", deleteMeetingRoomRequest, deleteMeetingRoomHeaders, new RuntimeOptions());
System.out.println(JSON.toJSONString(deleteMeetingRoomResponse.getBody()));
} catch (TeaException err) {
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
} catch (Exception _err) {
TeaException err = new TeaException(_err.getMessage(), _err);
if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
// err contains code and message attributes, which help locate the issue
System.out.println(err.code);
System.out.println(err.message);
}
}
}