我只是按照这份正式文件为借口成立团队。Create team 我还使用客户端凭证流并应用建议的所有权限。 在邮递员中,我使用此消息致电
{
"template@odata.bind":"https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
"displayName":"My Sample Team",
"description":"My Sample Team’s Description",
"members":[
{
"@odata.type":"#microsoft.graph.aadUserConversationMember",
"roles":[
"owner"
],
"userId":"xxxxx-61d8-43db-94f5-81374122dc7e"
}
]
}
但不幸的是会收到这样的错误消息,我对这个未知的错误完全感到困惑
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"date": "2020-11-02T05:32:08",
"request-id": "2955c466-f25f-42f5-ba89-4a522c428b70",
"client-request-id": "2955c466-f25f-42f5-ba89-4a522c428b70"
}
}
}
我也试图用C#代码执行它
var team = new Team
{
DisplayName = "My Sample Team558",
Description = "My Sample Team’s Description558",
Members = new TeamMembersCollectionPage() {
new AadUserConversationMember
{
Roles = new List<String>()
{
"owner"
},
UserId = "9xxxxxc9-f062-48e2-8ced-22xxxxx6dfce"
}
},
AdditionalData = new Dictionary<string, object>()
{
{"template@odata.bind", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}
}
};
var result = await graphServiceClient.Teams
.Request()
.AddAsync(team);
此异步调用将成功执行,还将创建一个新的team team团队,但是结果返回null,这意味着我无法从结果中获取team id。
我无法进行下一步,例如添加新频道等。
我在C#代码中使用Microsoft.Graph v3.18.0.0
。
答案 0 :(得分:1)
我可以轻松地重现您的问题。导致此错误的原因可能是您未授予必要的权限或未授予管理员对此权限的同意。
因此,您需要检查是否已授予必要的应用程序权限,并且已授予管理员同意。
代码:
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var team = new Team
{
DisplayName = "My Sample Team",
Description = "My Sample Team’s Description",
AdditionalData = new Dictionary<string, object>()
{
{"template@odata.bind", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}
}
};
await graphClient.Teams
.Request()
.AddAsync(team);