Microsoft Teams Graph API - 请求中的绑定属性名称所有者无效 [英] Microsoft Teams Graph API - Invalid bind property name owners in request

查看:61
本文介绍了Microsoft Teams Graph API - 请求中的绑定属性名称所有者无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm currently having major issues with creating teams from the Graph API. I was initially trying to create teams based on groups, however I have found out today that you can now create a team without creating a group first then waiting 15 minutes to then create the team from the following link. This would make things considerably simpler.

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 调用,如下所示.

I am using the Microsoft.Graph SDK (v3.12.0 released 26th Aug) so replicated the http call using the SDK as follows.

        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);

上面的代码给出了一个:

The code above gives a:

[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}')\"]"}

从代码中我得到以下内容:

from the code I get the following:

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

任何建议将不胜感激.

谢谢,尼克

推荐答案

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

In v1.0 the owners relationship is not currently present, so you have to use the beta endpoint. POST: https://graph.microsoft.com/beta/teams

具有以下正文格式

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

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

Note: the user guid should also be bare, i.e without the brackets and quotes in your example.

这篇关于Microsoft Teams Graph API - 请求中的绑定属性名称所有者无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆