简体   繁体   English

使用 Microsoft 图形 API 时创建团队团队错误

[英]Create a teams team error when using Microsoft graph api

I just follow this official document to excuse create a team.我只是按照这个官方文件来找借口创建一个团队。 Create team I also using the client credential flow and apply all the permissions advised. 创建团队我也使用客户端凭据流并应用建议的所有权限。 In Postman, I used this message to call在 Postman 中,我使用此消息调用

{
   "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"
      }
   ]
}

but unfortunately will get such error message, I'm fully confused on this unknown Error但不幸的是会收到这样的错误信息,我对这个未知的错误感到非常困惑

{
  "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"
    }
  }
}

I also tried to execute it in C# code我也尝试在 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);

This async call will be executed successfully and a new teams team will be also created, but the result return null, that means I could not get the team id from the result.这个异步调用会成功执行,也会创建一个新的团队团队,但结果返回空,这意味着我无法从结果中获取团队 id。 I could not go to the next step, such as add a new channel etc. I'm using Microsoft.Graph v3.18.0.0 in my C# code。我无法进行下一步,例如添加新频道等。我在我的 C# 代码中使用Microsoft.Graph v3.18.0.0

UPDATE Here is the accesstoken更新这是访问令牌在此处输入图片说明

I can easily reproduce your problem.我可以轻松重现您的问题。 The cause of this error may be that you did not grant the necessary permissions or did not grant the admin consent for this permission.此错误的原因可能是您未授予必要的权限或未授予管理员同意此权限。

在此处输入图片说明

Therefore, you need to check that you have granted the necessary application permissions and Permission is granted to the admin consent .因此,您需要检查您是否已授予必要的应用程序权限,并且 Permission 已授予管理员同意

在此处输入图片说明

在此处输入图片说明

code:代码:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用控制台应用程序通过 Microsoft Graph API 调用 Microsoft Teams OnlineMeeting 端点? - How do I Call Microsoft Teams OnlineMeeting endpoints via Microsoft Graph API using a console app? MS Teams 集成和 Microsoft Graph API - 调用事件时出错 API 列出日历 (/me/calendars) - MS Teams Integration & Microsoft Graph API - Error calling Events API List calendars (/me/calendars) 使用 Microsoft 团队创建用户故事 - Create user story using Microsoft teams 获取 Microsoft Teams 机器人的访问令牌以与图形 API 一起使用 - Get an access token for a bot with Microsoft Teams for use with graph API Microsoft Graph Api 使用 Microsoft 帐户创建用户, - Microsoft Graph Api Create User With Microsoft Account, Microsoft Graph API:获取团队(组)的渠道不起作用 - Microsoft Graph API: Getting channels of a Team(Group) is not working 如何使用 MS Graph 获取 Microsoft Teams 中的频道列表? - How to get a list of channels in Microsoft Teams using MS Graph? Microsoft graph API:与共享点和令牌一起使用时,出现未经授权的错误 - Microsoft graph API: unauthorized error when used with sharepoint and token attached 从Web API调用Microsoft图时出现无效的令牌错误 - Invalid token error when calling Microsoft graph from Web API 如何通过 Microsoft Graph API/SDK 向 Microsoft 团队发送自适应卡片? - How to send a Adaptive card to Microsoft teams via Microsoft Graph API/SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM