如何通过Graph API的onlineMeetings添加非Active Directory用户参会者
问题
使用Graph API创建在线会议时,发现添加Active Directory内部用户需传入identity->user->id(AD用户ID),但业务需要添加非AD外部用户。现有针对内部用户的调用代码可正常运行,但尝试直接用emailAddress字段添加外部用户时失败。
内部用户可正常运行的调用代码:
let data = { startDateTime: '2023-07-13T14:30:34.2444915-05:30', endDateTime: '2023-07-13T15:00:34.2464912-05:30', subject: 'Meeting with external participants2', isOnlineMeeting: true, allowAttendeeToEnableCamera: true, allowAttendeeToEnableMic: true, allowMeetNow: true, "participants": { "organizer": { "identity": { "user": { "upn": "abc@onmicrosoft.com" } } }, "attendees": [ { "upn": "user1@onmicrosoft.com", "identity": { "user": { "id": "a289c0ee-12d1-469f-be00-xyzavcddddd" } } }, { "upn": "user2@onmicrosoft.com", "identity": { "user": { "id": "1694c8f8-1db2-418e-8d9e-huwhdfiuhw" } } } ] } }; const headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }; axios.post(endpoint, data, { headers: headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error.response.data); });
尝试添加外部用户的失败代码片段:
attendees: [ { emailAddress: { address: 'abc@gmail.com', name: 'ABC' }, type: 'required' }, { emailAddress: { address: 'xyz@gmail.com', name: 'XYZ' }, type: 'optional' } ]
解决方案
添加非AD外部用户作为参会者时,需将外部用户信息嵌套在identity->guest结构下,而非直接使用emailAddress字段。正确的参会者格式如下:
修改后的完整请求数据示例
let data = { startDateTime: '2023-07-13T14:30:34.2444915-05:30', endDateTime: '2023-07-13T15:00:34.2464912-05:30', subject: 'Meeting with external participants2', isOnlineMeeting: true, allowAttendeeToEnableCamera: true, allowAttendeeToEnableMic: true, allowMeetNow: true, "participants": { "organizer": { "identity": { "user": { "upn": "abc@onmicrosoft.com" } } }, "attendees": [ // 内部AD用户 { "upn": "user1@onmicrosoft.com", "identity": { "user": { "id": "a289c0ee-12d1-469f-be00-xyzavcddddd" } } }, // 外部非AD用户(必填) { "identity": { "guest": { "emailAddress": { "address": "abc@gmail.com", "name": "ABC" } } }, "type": "required" }, // 外部非AD用户(可选) { "identity": { "guest": { "emailAddress": { "address": "xyz@gmail.com", "name": "XYZ" } } }, "type": "optional" } ] } }; const headers = { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json' }; axios.post(endpoint, data, { headers: headers }) .then(response => { console.log(response.data); }) .catch(error => { console.error(error.response.data); });
关键说明
- 外部用户必须通过
identity->guest节点传递邮箱和姓名信息,这是Graph API识别外部参会者的标准结构。 - 保持
type字段(required/optional)来指定参会者类型,与内部用户的使用方式一致。 - 内部用户和外部用户可以同时出现在
attendees数组中,无需特殊区分处理。
内容的提问来源于stack exchange,提问作者Girish Gupta
相关产品推荐
相关产品推荐

