无法从使用 Graph-API 的组创建 Microsoft Team。无法迁移该组

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

我正试图使用Microsoft Graph-API创建一个团队。我已经有一个现有的组,我想添加一个团队。我的代码看起来是这样的。

            var api = graphClients.GetClientForTenantId(tId);
            groupToAdd.MailEnabled = false;
            groupToAdd.SecurityEnabled = true;
            groupToAdd.MailNickname = RemoveWhitespace(groupToAdd.DisplayName);

            var directoryObject = new DirectoryObject
            {
                Id = userId
            };

            var team = new Team
            {
                MemberSettings = new TeamMemberSettings
                {
                    AllowCreateUpdateChannels = true,
                    ODataType = null
                },
                MessagingSettings = new TeamMessagingSettings
                {
                    AllowUserEditMessages = true,
                    AllowUserDeleteMessages = true,
                    ODataType = null
                },
                FunSettings = new TeamFunSettings
                {
                    AllowGiphy = true,
                    GiphyContentRating = GiphyRatingType.Strict,
                    ODataType = null
                },
                ODataType = null
            };

            var addedGroup = await api.Groups
                .Request()
                .AddAsync(groupToAdd);

            await api.Groups[addedGroup.Id].Owners.References
                .Request()
                .AddAsync(directoryObject);

            await api.Groups[addedGroup.Id].Team
                .Request()
                .PutAsync(team)

添加组和所有者的工作完全正常, 但当我试图创建团队,我得到这个错误消息。

Status Code: BadRequest
Microsoft.Graph.ServiceException: Code: BadRequest
Message: Cannot migrate this group, id: (id), access type: 
Inner error:
    AdditionalData:
    request-id: (request-id)
    date: (date)
ClientRequestId: (ClientRequestId)

我试着改变了一些设置,但没有什么真正的工作,我也无法从微软找到任何帮助,除了这个。

如果该组创建时间少于15分钟,由于复制延迟,创建团队调用有可能以404错误代码失败。建议的模式是重试三次Create team调用,两次调用之间有10秒的延迟。

如果你有什么想法,请告诉我,提前感谢!

MoritzP

c# microsoft-graph microsoft-teams microsoft-graph-teams microsoft-graph-groups
1个回答
0
投票

简短的回答,我不得不添加这个。

            groupToAdd.GroupTypes = new List<String>()
            {
                "Unified"
            };

之后,它的工作。

© www.soinside.com 2019 - 2024. All rights reserved.