如何使用SharePoint 2.0端点实现JSON Batching创建文件夹?
- 需求:通过JSON批量处理结合SharePoint 2.0端点,单次请求完成文件夹及子文件夹的层级创建;需同时兼容API 1.0操作(如创建站点,该操作不被Graph API支持)和2.0操作(如获取文件夹内容、上传文件等),因此必须使用SharePoint端点而非Graph API。
- 当前测试结果:使用Graph API批量端点
https://graph.microsoft.com/v1.0/$batch时,请求体可成功执行并返回201状态码;但使用SharePoint 2.0批量端点https://[TENANT].sharepoint.com/_api/v2.0/$batch时,返回400错误。 - 当前使用的请求体:
[ { "headers": { "Content-Type": "application/json", "Accept": "application/json" }, "body": { "@microsoft.graph.conflictBehavior": "fail", "folder": {} }, "url": "/sites/[SITE_ID]/drive/items/[ROOT_FOLDER_ID]:/Opportunità Latrinett", "method": "PATCH", "id": 1 }, { "headers": { "Content-Type": "application/json", "Accept": "application/json" }, "body": { "@microsoft.graph.conflictBehavior": "fail", "folder": {} }, "url": "/sites/[SITE_ID]/drive/items/[ROOT_FOLDER_ID]:/Opportunità Latrinett/Items", "method": "PATCH", "id": 2, "dependsOn": [ "1" ] }, { "headers": { "Content-Type": "application/json", "Accept": "application/json" }, "body": { "@microsoft.graph.conflictBehavior": "fail", "folder": {} }, "url": "/sites/[SITE_ID]/drive/items/[ROOT_FOLDER_ID]:/Opportunità Latrinett/Items/Master Folder", "method": "PATCH", "id": 3, "dependsOn": [ "2" ] }, { "headers": { "Content-Type": "application/json", "Accept": "application/json" }, "body": { "@microsoft.graph.conflictBehavior": "fail", "folder": {} }, "url": "/sites/[SITE_ID]/drive/items/[ROOT_FOLDER_ID]:/Opportunità Latrinett/Preventivi", "method": "PATCH", "id": 4, "dependsOn": [ "3" ] } ]
内容的提问来源于stack exchange,提问作者Christian Croce
相关产品推荐
相关产品推荐

