Microsoft Graph API-创建团队时隐藏的渠道

时间:2020-09-08 10:07:34

标签: c# microsoft-graph-api microsoft-teams microsoft-graph-teams

我正在使用HTTP客户端向Graph API发出请求,以创建具有多个通道的团队,所有内容均正确创建,但是通道显示为“隐藏”。

我已经尝试在频道上使用“ isFavoriteByDefault”属性,但没有任何效果。

我通过创建没有渠道的团队然后分别创建每个渠道来使其工作,但这太慢了。

如何在一个请求中创建团队和所有渠道,但使其可见?

我的代码:

HttpClient client = Client("https://graph.microsoft.com/v1.0/teams", token);

var data = new
{
    odataTemplateProperty = "https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
    visibility = "Private",
    displayName = Team.Name,
    description = Team.Description,
    channels = Channels.Select(x => new
    {
        odataProperty = "#Microsoft.Teams.Core.channel",
        membershipType = "private",
        isFavoriteByDefault = true,
        displayName = x.Name,
        description = x.Description
    }).ToList()
};

string jsonData = JsonConvert.SerializeObject(data).Replace("odataProperty", "@odata.type").Replace("odataTemplateProperty", "template@odata.bind");

StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");

var response = Post(client, content).Result;

0 个答案:

没有答案