【问题标题】:Microsoft Teams Graph API - Invalid bind property name owners in requestMicrosoft Teams Graph API - 请求中的绑定属性名称所有者无效
【发布时间】:2020-08-27 16:34:28
【问题描述】:

我目前在使用 Graph API 创建团队时遇到了重大问题。我最初尝试基于组创建团队,但是我今天发现您现在可以创建一个团队,而无需先创建一个组,然后等待 15 分钟,然后从以下链接创建团队。这将使事情变得相当简单。

https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0

我正在使用 Microsoft.Graph SDK(8 月 26 日发布的 v3.12.0),因此使用 SDK 复制了 http 调用,如下所示。

        var team = new Team
        {
            DisplayName = "My Group Name",
            Description = "My Group Description",
            AdditionalData = new Dictionary<string, object>()
            {
                {"template@odata.bind", "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"},
                {"owners@odata.bind", $"[\"https://graph.microsoft.com/v1.0/users('{usersGuid}')\"]"}
            },
        };

        var response = await _graphClient.Teams
            .Request()
            .AddAsync(team);

上面的代码给出了一个:

[16:14:01 ERR] An unhandled exception has occurred while executing the request.
Status Code: BadRequest
Microsoft.Graph.ServiceException: Code: BadRequest
Message: Invalid bind property name owners in request.

如果我删除该行

{"owners@odata.bind", $"[\"https://graph.microsoft.com/v1.0/users('{usersGuid}')\"]"}

从代码中我得到以下信息:

ErrorMessage : {"errors":[{"message":"A team owner must be provided when creating a team in application context."}]

任何建议将不胜感激。

谢谢, 尼克

【问题讨论】:

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


【解决方案1】:

在 v1.0 中,所有者关系当前不存在,因此您必须使用 beta 端点。 POST: https://graph.microsoft.com/beta/teams

具有以下正文格式

{ "template@odata.bind":"https://graph.microsoft.com/beta/teamsTemplates('standard')", "displayName":"Test Team", "description":"Test description", "owners@odata.bind":["https://graph.microsoft.com/v1.0/users/{user guid}"] }

注意:用户 guid 也应该是裸露的,即在您的示例中没有括号和引号。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多