简体   繁体   中英

How to add members as a group or mail list in MS Teams using graph API

When using the add members to a Microsoft Teams, I have no problems if the payload I pass is an individual user.

The documentation mentions it can accept a user , directoryObj or another group . In fact, the example payload is:

{
  "@odata.id": "https://graph.microsoft.com/v1.0/directoryObjects/{id}"
}

I created a mailing list, which is essentially just a group or directory object (not quite sure on which of the two) and tried the same API but I get the following error:

{
  "error": {
    "code": "Request_BadRequest",
    "message": "Only Users can be members of a Unified Group. paramName: Members, paramValue: , objectType: Microsoft.Online.DirectoryServices.Group",
    "innerError": {
      "request-id": "STRING_GOES_HERE",
      "date": "DATE_GOES_HERE"
    },
    "details": [
      {
        "target": "members",
        "code": "InvalidValue"
      }
    ]
  }
}

I don't think any part of my request is incorrect, running the directoryObjects subAPI (for the payload) returns the correct location which I can unpack members from, but I can't actually add the members inside it

This is included in the documentation you referenced (in bold):

You can add users or other groups. Important: You can add only users to Office 365 Groups.

You cannot add a Group to a Unified Group (aka Office 365 Group or Team). Only individual users can be members of these groups.

As to the difference between a group and a directory object, there isn't one. Every object within AAD is derived from a directoryObject . Think of a directoryObject like you would System.Object in .NET or java.lang.Object in Java. So a Group is a directoryObject and a User is a directoryObject but a Group is not a User.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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