目前我正在我的流程中执行这两个操作:-
通过组名获取组的Info,主要是PrincipleID
在另一个 POST 请求中传递组的 PrincipleID 以将组的权限分配给列表项
现在我想将 2 个请求加入到一个批次中的一个请求中,这是我计划使用的批次请求的正文:-
这是批量请求正文:-
--batch_1234
Content-Type: multipart/mixed; boundary="changeset_1234"
--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary
GET https://*****.sharepoint.com/sites/*****/_api/web/SiteUsers/GetByLoginName('*****')/Id HTTP/1.1
--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary
POST https://*****.sharepoint.com/sites/*****/_api/web/lists(****)/items(***)/roleassignments/addroleassignment(PrincipalId=**GET THE RESULT OF THE GET REQUEST**?['d']?['Id']},roleDefId=1073741826) HTTP/1.1
--changeset_1234--
--batch_1234--
但问题是我如何从 Get 请求的输出中获取 ID 并将其传递给同一个 Batch 请求正文中的 Post 请求??
谢谢
Batch Processing (OData Version 3.0)
2.2.1 Referencing Requests in a Change Set
。
您必须在第一个请求的标头中添加类似
Content-ID: 1
的内容,并在下一个请求中使用响应的值作为 $1
。
您的代码可能应该更改为(我让您在这里测试并评论最终答案,并且正如@Skin在评论中提到的那样,您可以使用ChatGPT索取更多示例):
--batch_1234
Content-Type: multipart/mixed; boundary="changeset_1234"
--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary
Content-ID: 42
GET https://*****.sharepoint.com/sites/*****/_api/web/SiteUsers/GetByLoginName('*****')/Id HTTP/1.1
--changeset_1234
Content-Type: application/http
Content-Transfer-Encoding: binary
POST https://*****.sharepoint.com/sites/*****/_api/web/lists(****)/items(***)/roleassignments/addroleassignment(PrincipalId=$42,roleDefId=1073741826) HTTP/1.1
--changeset_1234--
--batch_1234--