首页 > 解决方案 > 无法在 Microsoft Teams 中将 Planner 创建为选项卡

问题描述

我有一组无法添加 Microsoft Planner 选项卡的 Microsoft Teams。当我尝试添加 Planner 时,我会看到对话框并输入 Planner 名称并单击 Create,它会返回 Create Plan Failed 消息。不返回其他信息。

并非所有 Microsoft Team 都会发生这种情况,通常在 Teams 应用程序中创建的工作正常,但我通过 Microsoft Graph 创建的有此问题。这是我用来创建团队的代码。

public async Task<string> CreateTeam(string title, ClaimsPrincipal user)
{
    var userId = user.Claims.First(c => c.Type == "http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
    var body = $"{{\"displayName\":\"{title}\",\"groupTypes\":[\"Unified\"],\"mailEnabled\":true,\"mailNickname\":\"{title.Replace(" ", "")}\", \"securityEnabled\":false, \"visibility\":\"Private\" }}";
    var res = await GraphClient.QueryGraphAsyncPost($"/groups", body, user);
    var result = await res.Content.ReadAsStringAsync();
    var group = JsonConvert.DeserializeObject<FieldInfoBucket>(result);
    var id = group.Id;

    res = await GraphClient.QueryGraphAsync($"/groups/{id}/owners", user);
    result = await res.Content.ReadAsStringAsync();

    body = $"{{\"@odata.id\": \"https://graph.microsoft.com/beta/users/{userId}\"}}";
    res = await GraphClient.QueryGraphAsyncPost($"/groups/{id}/owners/$ref", body, user);
    // ReSharper disable once RedundantAssignment
    result = await res.Content.ReadAsStringAsync();

    body =
        $"{{\"memberSettings\":{{\"allowCreateUpdateChannels\":true, \"allowDeleteChannels\":true, \"allowAddRemoveApps\":true, \"allowCreateUpdateRemoveTabs\":true, \"allowCreateUpdateRemoveConnectors\":true}}, \"guestSettings\":{{\"allowCreateUpdateChannels\":false, \"allowDeleteChannels\":false}}, \"messageSettings\":{{\"allowUserEditMessages\":true, \"allowUserDeleteMessages\":true, \"allowOwnerDeleteMessages\":true, \"allowTeamMentions\":true, \"allowChannelMentions\":true}},\"funSettings\":{{\"allowGiphy\":true, \"giphyContentRating\":\"strict\",\"allowStickersAndMemes\":true,\"allowCustomMemes\":true}} }}";
    res = await GraphClient.QueryGraphAsyncPut($"/groups/{id}/team", body, user);
    // ReSharper disable once RedundantAssignment
    result = await res.Content.ReadAsStringAsync();

    return id;
}

上面的 Graph 客户端只是针对 graph.microsoft.com/beta 端点发出 Get/Post/Put 命令并添加适当的 Bearer 令牌。

标签: microsoft-graph-apimicrosoft-teams

解决方案


Planner 很困惑,因为它是由不是团队成员的用户询问的。如果我们使用/AddMember api显式添加当前登录用户(所有者),那么它工作正常。我们正在努力修复。


推荐阅读