简体   繁体   English

使用 Graph API 将成员添加到 MS Teams

[英]Add a member to MS Teams using Graph API

I am attempting to add a member to my MS Team using the Graph API and an Azure app token:我正在尝试使用 Graph API 和 Azure 应用程序令牌将成员添加到我的 MS 团队:

Endpoint: https://graph.microsoft.com/v1.0/teams/c924e9b8-*****/members

Body:
'@odata.type':'#microsoft.graph.aadUserConversationMember'
'roles':'[]'
'user@odata.bind':'https://graph.microsoft.com/v1.0/users('41134b16-6f68*****')

When I send this request I am getting:当我发送此请求时,我得到:

"code": "InternalServerError"
"message": "Failed to execute request."

I can't seem to find any information on what this error means.我似乎找不到有关此错误含义的任何信息。 Is anyone familiar with this error?有人熟悉这个错误吗?

The issue must be due to Web App token generated from Developer portal.该问题一定是由于从开发人员门户生成的 Web 应用程序令牌。

Steps to Resolve:解决步骤:

  • Check if the required permissions are provided to the app registration you are using for the webapp ie TeamMember.ReadWriteNonOwnerRole.All with admin consent like below:检查是否为您用于 web 应用程序的应用程序注册提供了所需的权限,即TeamMember.ReadWriteNonOwnerRole.All并获得管理员同意,如下所示:

    在此处输入图像描述

  • Go to Postman>>new_request>>authorization>>Select Oauth2.0 in type >> select Grant type as Client Credential >> fill necessary details provided below and then click on new access token. Go to Postman>>new_request>>authorization>> Oauth2.0 in type >> select Grant type as Client Credential >>填写下面提供的必要详细信息,然后单击新的访问令牌。

     Access Token URL: https://login.microsoftonline.com/my-tenant-id/oauth2/v2.0/token ClientId: azure ad App reg ID ClientSecret: Secret generated for the same app scope: https://graph.microsoft.com/.default

    在此处输入图像描述

  • Once the above is done you will be successfully able to do the operation:完成上述操作后,您将能够成功执行操作:

    在此处输入图像描述

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM