使用 microsoft graph 创建团队时出现 Odata.bind 错误 [英] Odata.bind error when creating a team with microsoft graph

查看:25
本文介绍了使用 microsoft graph 创建团队时出现 Odata.bind 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 .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.

为此,我按照此处文档中要求的步骤操作:https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-beta&tabs=csharp#example-4-create-a-team-from-group

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

我已经尝试了 Microsoft 文档中的一系列示例,包括 v1.0 和测试版.

I already tried a bunch of example from the Microsoft documentation, from the v1.0 and beta one.

我创建的群组如下所示:

My group creation looks like this:

        {
            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 的文档?

So here is my question: What am I doing wrong? Is it a syntax error? Where I can find a documentation about Odata.bind?

推荐答案

我解决了这个问题 post

我为每个创建的对象添加了一个属性 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 graph 创建团队时出现 Odata.bind 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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