【发布时间】:2018-05-31 16:19:57
【问题描述】:
我有一组 Microsoft Teams,我无法向其中添加 Microsoft Planner 选项卡。当我尝试添加 Planner 时,我会看到对话框并输入 Planner 名称并单击 Create,它会返回 Create Plan Failed 消息。不返回其他信息。
这种情况并非在所有 Microsoft Team 中都会发生,通常在团队应用程序中创建的团队可以正常工作,但我通过 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 令牌。
【问题讨论】:
-
Planner 很困惑,因为不是团队成员的用户询问了它。如果我们使用/AddMember api 显式添加当前登录用户(所有者),那么它工作正常。我们正在努力修复。同时,请您在最后尝试一下并确认吗?
标签: microsoft-graph-api microsoft-teams