在给定 SharePoint URL 并使用 Graph API 的情况下枚举特定驱动器的 DriveItem 资源
Enumerate DriveItem resources of a specific Drive given SharePoint URL and using Graph API
我有一个 https://organizationname.sharepoint.com/sites/... 形式的 SharePoint URL。
我想使用图表 API 获取此驱动器中所有资源的列表。阅读 API documentation 看来我需要此驱动器的 drive-id 才能执行此请求。
/drives/{drive-id}/root/children
此外,根据对类似 的回答,似乎没有 API 可以将 SharePoint URL 转换为 OneDrive driveId。有可能的解决方法吗?有没有办法以编程方式从 SharePoint URL 获取资源列表?
如果您的 SharePoint URL 是 https://organizationname.sharepoint.com/sites/yourSiteName
,那么您可以通过图表 API 发出这样的请求(可能需要范围 Sites.Read.All
):
client.api("/sites/organizationname.sharepoint.com:/sites/yourSiteName:/drives").get();
该请求将 return 像这样:
{
"@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": "bla@organizationame.onmicrosoft.com",
"id": "12345678-4321-4321-4321-012345678901",
"displayName": "zz"
}
},
"owner": {
"group": {
"email": "x@y.onmicrosoft.com",
"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 获取资源列表,但您可以使用两个 Graph API 请求实现相同的目的.
我有一个 https://organizationname.sharepoint.com/sites/... 形式的 SharePoint URL。
我想使用图表 API 获取此驱动器中所有资源的列表。阅读 API documentation 看来我需要此驱动器的 drive-id 才能执行此请求。
/drives/{drive-id}/root/children
此外,根据对类似
如果您的 SharePoint URL 是 https://organizationname.sharepoint.com/sites/yourSiteName
,那么您可以通过图表 API 发出这样的请求(可能需要范围 Sites.Read.All
):
client.api("/sites/organizationname.sharepoint.com:/sites/yourSiteName:/drives").get();
该请求将 return 像这样:
{
"@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": "bla@organizationame.onmicrosoft.com",
"id": "12345678-4321-4321-4321-012345678901",
"displayName": "zz"
}
},
"owner": {
"group": {
"email": "x@y.onmicrosoft.com",
"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 获取资源列表,但您可以使用两个 Graph API 请求实现相同的目的.