0

使用Microsoft Teams Portal,我创建了一个随作业笔记本选项卡一起提供的。我想以编程方式创建一个类似的组。

我正在使用 Nuget Microsoft.Graph.Beta 4.0.1-preview在 Microsoft Teams 上以编程方式为学校教室创建团队。但是我注意到创建的团队没有Assignments选项卡也没有Notebook。然后我与我在团队门户上创建的团队进行比较,发现在团队门户上手动创建的团队creationOptions在类上有这个Group

 "creationOptions": ["classAssignments", "ExchangeProvisioningFlags:2509"]

但在 API 创建的组中,它不包含该组。API 也没有该字段creationOptions

API

使用 API 创建时如何添加该信息?或者在创建团队后如何添加这些选项?


我也试过这个:

var grupo = await graphClient.Groups.Request().AddAsync(new Group()
        {
            DisplayName = "Turma Dialética 2021",
            Description = "Grupo da Turma Dialética 2021",
            MailNickname = "f958e37c-f093-4177-8de4-2f86bfaba624",
            MailEnabled = false,
            SecurityEnabled = false,
            GroupTypes = new string[] { "Unified" },
            Visibility = "HiddenMembership",//
            AdditionalData = new Dictionary<string, object>()
            {
                {"creationOptions", new List<string> { "classAssignments", "ExchangeProvisioningFlags:2509" } }
            }
        }
        );

发送此 JSON 有效负载

{
  "description": "Grupo da Turma Dialética 2021",
  "displayName": "Turma Dialética 2021",
  "groupTypes": [
    "Unified"
  ],
  "mailEnabled": false,
  "mailNickname": "f958e37c-f093-4177-8de4-2f86bfaba624",
  "securityEnabled": false,
  "visibility": "HiddenMembership",
  "@odata.type": "microsoft.graph.group",
  "creationOptions": [
    "classAssignments",
    "ExchangeProvisioningFlags:2509"
  ]
}

但是当我添加这个 AdditionalData 时,就会发生这个异常:

Microsoft.Graph.ServiceException:'代码:Request_BadRequest 消息:找到没有类型名称的值,并且没有可用的预期类型。指定模型时,有效负载中的每个值都必须具有可以在有效负载中指定、由调用者显式指定或从父值隐式推断的类型。内部错误:AdditionalData:日期:2021-04-08T21:14:22 request-id: d3a0b0d3-5940-46d8-8188-56a1eaf5d350 client-request-id: d3a0b0d3-5940-46d8-8188-56a1eaf5d350`

如果我在单词 creationOptions 前面添加一个 @ 符号。例如“@creationOptions”然后在创建组时没有错误,但是当我尝试从该组创建团队时:

    var team = new Microsoft.Graph.Team()
    {
        MemberSettings = new TeamMemberSettings()
        {
            AllowCreateUpdateChannels = false
        },
        MessagingSettings = new TeamMessagingSettings()
        {
            AllowUserEditMessages = false,
            AllowUserDeleteMessages = false
        },
        FunSettings = new TeamFunSettings()
        {
            AllowGiphy = false
        }
        ,
        AdditionalData = new Dictionary<string, object>()
        {
            {"template@odata.bind", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"},
            {"group@odata.bind", "https://graph.microsoft.com/v1.0/groups('" + grupo.Id + "')"}
        }
    };
    graphClient.Teams.Request().AddAsync(team);

发生此错误:

Microsoft.Graph.ServiceException: 'Code: NotFound
Message: Failed to execute Templates backend request CreateTeamFromGroupWithTemplateRequest. Request Url: https://teams.microsoft.com/fabric/amer/templates/api/groups/9ee04411-993b-45f9-8d72-63343f703105/team, Request Method: PUT, Response Status Code: NotFound, Response Headers: Strict-Transport-Security: max-age=2592000
x-operationid: e922312859272d4ea8573cef70e37163
x-telemetryid: 00-e922312859272d4ea8573cef70e37163-0b5da564c6209441-00
X-MSEdge-Ref: Ref A: 34D331F1C0454DA7AE8CD7497D0558A7 Ref B: DM2EDGE1008 Ref C: 2021-04-09T15:16:22Z
Date: Fri, 09 Apr 2021 15:16:23 GMT
, ErrorMessage : {"errors":[{"message":"Failed to execute GetGroupAsync.","errorCode":"Unknown"}],"operationId":"e922312859272d4ea8573cef70e37163"}
Inner error:
    AdditionalData:
    date: 2021-04-09T15:16:24
    request-id: d5ef1a33-d6d9-4d30-b9c5-83a7a477a1b5
    client-request-id: d5ef1a33-d6d9-4d30-b9c5-83a7a477a1b5
ClientRequestId: d5ef1a33-d6d9-4d30-b9c5-83a7a477a1b5
'
4

2 回答 2

2

POST 到 /teams 端点时,您需要绑定正确的模板。EducationClass 模板应在 Teams 中创建正确的原语,并在 Group 的后台设置正确的选项。

从 POST /teams 文档页面:

POST https://graph.microsoft.com/beta/teams
Content-Type: application/json
{
  "template@odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('educationClass')",
  "displayName": "My Class Team",
  "description": "My Class Team’s Description"
}
于 2021-04-13T03:55:17.287 回答
0

该属性似乎没有在元数据中定义,因此它在 SDK 中不可用。但是,如果您查看组继承自的实体的定义(通过目录对象),您会发现 additionalData 属性。

使用类似下面的代码片段设置信息应该允许您将所需的信息传递给服务。

AdditionalData = new Dictionary<string, object>()
{
    {"@creationOptions", new List<string> { "classAssignments", "ExchangeProvisioningFlags:2509" } }
}

键前面的@符号是因为这个属性是一个实例注解

于 2021-04-08T20:22:51.430 回答