微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用Microsoft图形API时出现团队团队错误

如何解决使用Microsoft图形API时出现团队团队错误

我只是按照这份正式文件为借口成立团队。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

更新 这是访问令牌

enter image description here

解决方法

我可以轻松地重现您的问题。导致此错误的原因可能是您未授予必要的权限或未授予管理员对此权限的同意。

enter image description here

因此,您需要检查是否已授予必要的应用程序权限,并且已授予管理员同意

enter image description here

enter image description here

代码:

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);

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。