Microsoft Teams Graph API不支持发送Microsoft Teams邀请

时间:2019-12-18 02:42:17

标签: api graph microsoft-teams invite microsoft-graph-teams

我无法弄清楚如何向我克隆的Microsoft Teams团队添加成员。任何帮助,我们将不胜感激。

我创建了一个以自己为所有者的Microsoft Teams Team。如果以编程方式创建和分配,则该成员用户不会出现在团队中。

创建成员用户的步骤如下。 1.通过Microsoft Graph API使用“创建邀请”在活动目录中创建用户 2.通过Microsoft Graph API测试添加组成员

以下Microsoft Graph查询返回在活动目录和组中创建的用户。 1.通过Microsoft Graph API列出Active Directory用户 2.通过Microsoft Graph API列出Teams组中的成员。

下面您将找到我的代码和屏幕截图。

using (var client = new HttpClient())
{
    object data = new
    {
        invitedUserEmailAddress = "sean_dorsett@hotmail.com",
        inviteRedirectUrl = "https://teams.microsoft.com/",
        sendInvitationMessage = true
    };

    var defaultRequetHeaders = client.DefaultRequestHeaders;
    if (defaultRequetHeaders.Accept == null || !defaultRequetHeaders.Accept.Any(m => m.MediaType == "application/json"))
    {
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    }
    defaultRequetHeaders.Authorization = new AuthenticationHeaderValue("bearer", result.AccessToken);

    var myContent = JsonConvert.SerializeObject(data);
    var buffer = System.Text.Encoding.UTF8.GetBytes(myContent);
    var byteContent = new ByteArrayContent(buffer);
    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    var response = await client.PostAsync("https://graph.microsoft.com/v1.0/invitations", byteContent);
    var contents = await response.Content.ReadAsStringAsync();

    string jsonData = "{\"@odata.id\":\"https://graph.microsoft.com/v1.0/users/{guid}\"}";
    buffer = System.Text.Encoding.UTF8.GetBytes(jsonData);
    byteContent = new ByteArrayContent(buffer);
    byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
    response = await client.PostAsync("https://graph.microsoft.com/v1.0/groups/{guid}/members/$ref", byteContent);
    contents = await response.Content.ReadAsStringAsync();
}

Active Directory User Listing

Active Directory Groups Listing

Microsoft Teams Group

Microsoft Teams Group Member Listing

0 个答案:

没有答案