如何解决Microsoft Teams Graph API-请求中的无效绑定属性名称所有者
我目前在使用Graph API创建团队时遇到重大问题。我最初尝试创建基于组的团队,但是今天我发现您现在可以创建一个团队,而无需先创建组,然后等待15分钟再通过以下链接创建团队。这将使事情变得更加简单。
https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0
我正在使用Microsoft.Graph SDK(v3.12.0,8月26日发布),因此使用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."}]
任何建议将不胜感激。
谢谢, 尼克
解决方法
在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也应该是裸露的,即您的示例中没有方括号和引号。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。