将多个 PrincipleID 传递到 SharePoint Online REST API 内的角色分配/地址分配端点

问题描述 投票:0回答:1

我有一个云流,它获取一个以分号分隔的字符串,其中包含 Office 365 安全组名称。然后我在分割字符串后构建一个数组。

之后,对于每个组名称,我都会获取组 PrincipleID,然后将该组添加到具有读取角色的项目权限中。有时此数组包含 5 个组名称。因此,我将分别将每个组分配给列表项,这可能不是最好的方法。 因此,我希望将所有 5 个组 PrincipleID 一次性传递到 SharePoint。

那么有没有办法将组的原则 ID 列表传递到角色分配/地址分配端点,而不是仅传递单个原则 ID?请记住,所有小组都会阅读。

这是我当前的流程:-

enter image description here

enter image description here

有没有办法在这个 Uri 中传递多个 Principleds:-

_api/web/lists('*ListName*')/items(*ItemNumber*)/roleassignments/addroleassignment(PrincipalId=*PrincipleID*,roleDefId=1073741826)
office365 sharepoint-online sharepoint-rest-api
1个回答
0
投票

是的,使用 SharePoint Online REST API,您可以在一次调用中批量多个请求。例如,您可以调用多个

GET
来读取数据,或者调用多个
POST
DELETE
来编辑或删除 SharePoint 列表上的项目。

参考资料:

来自 Microsoft Learn 的示例:

POST https://fabrikam.sharepoint.com/_api/$batch HTTP/1.1
Content-Type: multipart/mixed; boundary=batch_e3b6819b-13c3-43bb-85b2-24b14122fed1

--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1
Content-Type: application/http
Content-Transfer-Encoding: binary

GET https://fabrikam.sharepoint.com/_api/Web/lists/getbytitle('Composed%20Looks')/items?$select=Title HTTP/1.1

--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1
Content-Type: application/http
Content-Transfer-Encoding: binary

GET https://fabrikam.sharepoint.com/_api/Web/lists/getbytitle('User%20Information%20List')/items?$select=Title HTTP/1.1

--batch_e3b6819b-13c3-43bb-85b2-24b14122fed1--

在 Power Automate 中,通过操作

Send an HTTP request to SharePoint
,您可以实现您的要求。先决条件是将您的 id 与
Select
Compose
(+
join
方法)连接起来。

参数应该是这样的:

身体:

--batch_1234
Content-Type: multipart/mixed; boundary=changeset_1234

--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary

POST https://your-tenant.sharepoint.com/sites/your-site/_api/web/lists/GetByTitle('Your-List')/items(123)/roleassignments/addroleassignment(PrincipalId=000000001001,roleDefId=1073741826) HTTP/1.1

--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary

POST https://your-tenant.sharepoint.com/sites/your-site/_api/web/lists/GetByTitle('Your-List')/items(123)/roleassignments/addroleassignment(PrincipalId=000000001002,roleDefId=1073741826) HTTP/1.

--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary

POST https://your-tenant.sharepoint.com/sites/your-site/_api/web/lists/GetByTitle('Your-List')/items(123)/roleassignments/addroleassignment(PrincipalId=000000001003,roleDefId=1073741826) HTTP/1.1

--changeset_1234--
--batch_1234--

有用的文章:在 Power Automate 中编写批量 SharePoint API 调用

© www.soinside.com 2019 - 2024. All rights reserved.