我正在使用带有.net核心的miscrosoft图在Microsoft Teams中创建一个团队。但是,当我发送团队创建请求时,总是会收到错误消息:
请求中的绑定属性名称模板无效。
为此,我按照此处的文档中的步骤进行操作: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文档中尝试了一堆示例。
我的群组创建如下:
{
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));
我的团队创建看起来像这样:
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的文档?
答案 0 :(得分:1)
我通过此post
解决了我的问题我为创建的每个对象都放置了一个属性ODataType = null
。
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);