microsoft-graph-api - 无法在 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 令牌。
解决方案
Planner 很困惑,因为它是由不是团队成员的用户询问的。如果我们使用/AddMember api显式添加当前登录用户(所有者),那么它工作正常。我们正在努力修复。
推荐阅读
- ios - 以下2行有什么区别?
- android - 如果设备正在充电且电池电量已满,如何开始活动?
- sql-server - MSSQL 问题休眠标准
- c++ - 使用 Eigen 标头的模板函数
- firebase - Firebase Firestore 中的哨兵是什么?
- python - Python 将字符串日期转换为 YYYY/MM/DD 日期时间对象
- c# - c# wpf ContentControl和多个UserControls
- mysql - 用于大量 MySQL 连接的 Zabbix 触发器
- typescript - moduleResolution 是节点,但编译时间与运行时间不同
- swift - let realm = Realm() 冻结了我的应用