我的 SharePoint URL 格式为 https://organizationname.sharepoint.com/sites/... .
我想使用图形 API 获取此驱动器中所有资源的列表。阅读API documentation我似乎需要该驱动器的驱动器 ID 才能执行此请求。
/drives/{drive-id}/root/children
另外,根据类似stackoverflow question的回答似乎没有 API 可将 SharePoint URL 转换为 OneDrive DriveId。有可能的解决方法吗?有没有办法以编程方式从 SharePoint URL 获取资源列表?
最佳答案
如果您的 SharePoint URL 是 https://organizationname.sharepoint.com/sites/yourSiteName
,那么您可以通过 Graph API 发出类似的请求(范围 Sites.Read.可能需要全部
):
client.api("/sites/organizationname.sharepoint.com:/sites/yourSiteName:/drives").get();
该请求将返回如下内容:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
"value": [
{
"createdDateTime": "2021-07-24T23:35:00Z",
"description": "",
"id": "b!A1234567-ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210",
"lastModifiedDateTime": "2021-08-12T16:39:23Z",
"name": "Dokumente",
"webUrl": "https://organizationname.sharepoint.com/sites/yourSIteName/folderName",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "abc"
}
},
"lastModifiedBy": {
"user": {
"email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="15777974557a6772747b7c6f74617c7a7b7478703b7a7b787c76677a667a73613b767a78" rel="noreferrer noopener nofollow">[email protected]</a>",
"id": "12345678-4321-4321-4321-012345678901",
"displayName": "zz"
}
},
"owner": {
"group": {
"email": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfc7ffc691d0d1d2d6dccdd0ccd0d9cb91dcd0d2" rel="noreferrer noopener nofollow">[email protected]</a>",
"id": "09876543-1234-1234-1234-012345678901",
"displayName": "Owner of something"
}
},
"quota": {
"deleted": 345678,
"remaining": 27487788453406,
"state": "normal",
"total": 27487790694400,
"used": 96120
}
}
]
}
description
下的 id
是drive-id
。这样你就可以得到 /root/children
像这样:
client.api("/sites/yourorganizationname.sharepoint.com/drives/b!A1234567-ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210/root/children").get();
虽然没有单一的 API 或算法允许您以编程方式从 SharePoint URL 获取资源列表,但您可以通过两个图形 API 请求实现相同的目的。
关于microsoft-graph-api - 枚举给定 SharePoint URL 并使用 Graph API 的特定驱动器的 DriveItem 资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68809707/