我正在尝试获取我需要的 SharePoint 文件夹的驱动器项目 ID,以便将文件上传到该文件夹。对于一个 SharePoint 网站,这工作正常,但对于另一网站,返回值始终为空。有谁知道,为什么会出现这种情况?
我的图 api 获取请求具有以下形式
https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/Items?$filter= Name eq '{foldername}'
其中 site-id 和 Drive-id 是我在之前的查询中检索到的 id。
在它工作的 SharePoint 网站上,我得到这样的答案,从中我需要返回的 id:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('{site-id}')/drives('{drive-id}')/items",
"value": [
{
"@odata.etag": "\"{guid},2\"",
"createdDateTime": "2024-09-02T12:41:17Z",
"eTag": "\"{guid},2\"",
"id": "{driveitemid}",
"lastModifiedDateTime": "2024-09-02T12:41:19Z",
"name": "{name-of-my-folder}",
"size": 1424250,
"webUrl": "{site-url}/CRM/{url-encoded-folder name}",
"cTag": "\"c:{guid},0\"",
"title": "{folder name}",
"createdBy": {
...
},
"lastModifiedBy": {
...
},
"parentReference": {
"driveId": "{drive-id}",
"driveType": "documentLibrary",
"id": "{some other id}",
"path": "/drives/{drive-id}/root:",
"sharepointIds": {
"listId": "{list-id}",
"listItemUniqueId": "...",
"siteId": "{site-id}",
"siteUrl": "{site-url}",
"tenantId": "...",
"webId": "..."
}
},
"commentSettings": {
"commentingDisabled": {
"isDisabled": false
}
},
"fileSystemInfo": {
"createdDateTime": "2024-09-02T12:41:17Z",
"lastModifiedDateTime": "2024-09-02T12:41:19Z"
},
"folder": {
"childCount": 7,
"view": {}
},
"shared": {
...
}
}
],
"@odata.nextLink": "https://graph.microsoft.com/v1.0/sites/{site-id}/drives/{drive-id}/Items?$filter=name+eq+foldername&$skiptoken=..."
}
在它不起作用的网站上,该值只是空的,响应如下所示:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites('{site-id2}')/drives('{}drive-id2')/items",
"value": [],
"@odata.nextLink": "https://graph.microsoft.com/v1.0/sites/{site-id2}/drives/{drive-id2}/Items?$filter=name+eq+foldername2"
}
是否有一个需要此功能才能运行的 SharePoint 设置,但未在第二个站点上设置?
已经检查了明显的坑:文件夹存在,并且文件夹名称没有错别字。
API 只查询一定数量的商品,当这些商品没有查询到结果时,会返回一个 nextLink 供您查询下一页商品。 继续查询结果中提供的nextLink,直到不再返回为止。 https://learn.microsoft.com/en-us/graph/paging?tabs=http