在 Microsoft Graph API 中创建具有所有者的组 [英] Create a Group in Microsoft Graph API with a Owner

查看:15
本文介绍了在 Microsoft Graph API 中创建具有所有者的组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a Office 365 Group that I would like to add through the Microsoft Graph API. Based on the API documentation, I believe I need

POST https://graph.microsoft.com/v1.0/groups
Content-type: application/json
Content-length: 244

{
  "description": "Self help community for library",
  "displayName": "Library Assist",
  "groupTypes": [
    "Unified"
  ],
  "mailEnabled": true,
  "mailNickname": "library",
  "securityEnabled": false
}

But when I try to add

"owner": [{ "@odata.id": "https://graph.microsoft.com/v1.0/users/{id}"}]

I get an error (The id is really an id that exists in the office so I don't want to put it here).

They work if I first run the create group and then the add owner but not together. Why?

Would like to make it as easy for me as possible. I'm putting postman in the tags just because that's the tools I'm currently using

解决方案

Actually this is supported and possible today using OData bind syntax (i.e. your syntax is incorrect). NOTE: This is our bad, not your, because we haven't documented this supported behavior. I'll file a bug on our side to document this.

In the meantime, try adding this to your request (it worked for me), and let us know if this works for you:

"owners@odata.bind": ["https://graph.microsoft.com/v1.0/users/{id}"]

In fact, in the same request you can also bind members as part of the request:

"owners@odata.bind": [ "https://graph.microsoft.com/v1.0/users/{id1}" ], "members@odata.bind": [ "https://graph.microsoft.com/v1.0/users/{id1}", "https://graph.microsoft.com/v1.0/users/{id2}" ]

Not sure what the limits are on the number of items you can put in the binding collection, but I'm sure there is one. I'll see if one of the devs can comment on this.

Hope this helps,

这篇关于在 Microsoft Graph API 中创建具有所有者的组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆