使用Microsoft图形创建团队时出现Odata.bind错误 [英] Odata.bind error when creating a team with microsoft graph
问题描述
我正在使用带有.net核心的miscrosoft图在Microsoft Teams中创建一个团队.但是,当我发送团队创建请求时,总是会收到错误消息:
I'm using miscrosoft graph with .net core to create a team in Microsoft Teams. But when I send the request for the team creation I always get an error message:
请求中的绑定属性名称模板无效.
Invalid bind property name template in request.
To do that, I followed the step required in the documentation here: https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-beta&tabs=csharp#example-4-create-a-team-from-group
我已经从v1.0和beta版本的Microsoft文档中尝试了一堆示例.
I already tried a bunch of example from the Microsoft documentation, from the v1.0 and beta one.
我的群组创建如下:
{
var email = groupName.ToLower().Replace(" ", "_");
//Create a new object group
Group group = new Group
{
DisplayName = groupName,
GroupTypes = new List<string>()
{
"Unified",
},
MailEnabled = true,
MailNickname = email,
SecurityEnabled = false,
AdditionalData = additionnalData,
};
附加数据为:
var additionalData = new Dictionary<string, object>()
{
{"members@odata.bind", new List<string>()},
{"owners@odata.bind", new List<string>()}
};
(additionalData["members@odata.bind"] as List<string>).Add(TeamsApi.GetUserOData(ownerEmail));
(additionalData["owners@odata.bind"] as List<string>).Add(TeamsApi.GetUserOData(ownerEmail));
我的团队创建看起来像这样:
And my team creation look like this:
Team team = new Team
{
AdditionalData = new Dictionary<string, object>()
{
{"group@odata.bind",$"https://graph.microsoft.com/v1.0/groups({newGroupId})"},
{"template@odata.bind","https://graph.microsoft.com/beta/teamsTemplates('standard')"},
},
};
return await GraphClient.Groups[newGroupId].Team.Request().PutAsync(team);
所以这是我的问题:我做错了什么?这是语法错误吗?在哪里可以找到有关Odata.bind的文档?
So here is my question: What am I doing wrong? Is it a syntax error? Where I can find a documentation about Odata.bind?
推荐答案
我使用此我对创建的每个对象都添加了属性 ODataType = null
.
I put a property ODataType = null
to every object created.
Team team = new Team
{
ODataType = null,
Channels = new TeamChannelsCollectionPage(),
};
Channel general = new Channel
{
DisplayName = "Général",
ODataType = null
};
team.Channels.Add(general);
return await GraphClient.Groups[newGroupId].Team.Request().PutAsync(team);
这篇关于使用Microsoft图形创建团队时出现Odata.bind错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!