The*_*eek 5 sharepoint microsoft-graph-files microsoft-graph-api
我正在尝试使用 Microsoft Graph API 从 SharePoint 文档库获取文件夹和文档。
\n\n如果我请求GET,https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MyDocumentSite:/drives/我会得到这个:
{\n "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",\n "value":[\n {\n "createdDateTime": "2019-09-05T07:09:49Z",\n "description": "",\n "id": "b!wxh2ZWwoT0KKTdLRYjD5jvzjo8jkat5LgY3VyfgEqkv3YVg_XXXXXXXXXXXXXXXX",\n "lastModifiedDateTime": "2019-09-05T07:09:49Z",\n "name": "Documents",\n "webUrl": "https://mysite.sharepoint.com/sites/MyDocumentSite/Shared%20Documents",\n "driveType": "documentLibrary",\n "createdBy":{"user":{"displayName": "System Account" }},\n "lastModifiedBy":{"user":{"email": "me@myorganization.org", "id": "73f9990c-5c92-4839-8b13-XXXXXXXXXXXX", "displayName": "John Smith"\xe2\x80\xa6},\n "quota":{"deleted": 0, "remaining": 0, "total": 0, "used": 0}\n }\n ]\n}\nRun Code Online (Sandbox Code Playgroud)\n\n但是,如果我尝试通过GET对该 id: 执行请求来访问该驱动器https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MyDocumentSite:/drives/b!wxh2ZWwoT0KKTdLRYjD5jvzjo8jkat5LgY3VyfgEqkv3YVg_XXXXXXXXXXXXXXXX,则会收到 BadRequest 错误:
{\n "error":{\n "code": "BadRequest",\n "message": "Url specified is invalid.",\n "innerError":{\n "request-id": "7c9eaf61-764f-4d72-abdb-ffa2fe868e90",\n "date": "2019-09-16T19:09:41"\n }\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n最终,我想要一种方法来显示文档库中的所有文件夹和文档,但我似乎无法完成这个初始步骤。
\n事实上,当站点通过站点路径寻址时,以下查询会失败并出现异常:
GET `https://graph.microsoft.com/v1.0/sites/{hostname}:/{server-relative-path}/drive/root/children`
Run Code Online (Sandbox Code Playgroud)
这似乎是一个错误,因为类似的查询但当站点由 id 寻址时,它按预期工作:
GET https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root/children
Run Code Online (Sandbox Code Playgroud)
要考虑的另一个选项是通过标识符获取Drive资源(不指定站点路径或标识符),例如:
GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root/children
Run Code Online (Sandbox Code Playgroud)
当轮到获取库中的所有文档和文件夹时,List children of a driveItem端点仅返回当前文件夹下的一级。
要返回所有驱动器项目,您至少可以考虑:
search方法,例如GET
https://graph.microsoft.com/v1.0/drives/{drive-id}/root/search(q='')List children of a driveItem使用“delta”API: https://learn.microsoft.com/en-us/graph/api/driveitem-delta ?view=graph-rest-1.0&tabs=http
第一次调用将返回所有项目。(如果有分页,您需要调用 nextLink,直到收到 deltaLink)。
您可能想要使用一个
GET /sites/{siteId}/drive/root/delta
或
GET /drives/{drive-id}/root/delta
| 归档时间: |
|
| 查看次数: |
19323 次 |
| 最近记录: |