我正在尝试使用 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 错误代码。推荐的模式是重试创建团队调用 3 次,调用之间有 10 秒的延迟。
哈哈
如果您有任何想法,请告诉我,提前谢谢!
莫里茨