[使用Microsoft图形创建团队时出现Odata.bind错误

问题描述 投票:0回答:1

我正在使用具有.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>()
            {
                {"[email protected]", new List<string>()},
                {"[email protected]", new List<string>()}
            };
            (additionalData["[email protected]"] as List<string>).Add(TeamsApi.GetUserOData(ownerEmail));
            (additionalData["[email protected]"] as List<string>).Add(TeamsApi.GetUserOData(ownerEmail));

我的团队创作看起来像这样:

            Team team = new Team
            {
                AdditionalData = new Dictionary<string, object>()
                {
                    {"[email protected]",$"https://graph.microsoft.com/v1.0/groups({newGroupId})"},
                    {"[email protected]","https://graph.microsoft.com/beta/teamsTemplates('standard')"},
                },

            };
            return await GraphClient.Groups[newGroupId].Team.Request().PutAsync(team);

所以这是我的问题:我做错了什么?这是语法错误吗?在哪里可以找到有关Odata.bind的文档?

.net-core microsoft-graph microsoft-graph-sdks microsoft-graph-teams
1个回答
0
投票

我已解决此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);
© www.soinside.com 2019 - 2024. All rights reserved.