【发布时间】:2021-07-19 09:38:47
【问题描述】:
我正在尝试弄清楚如何为 Microsoft graph API 的共享点站点中的文件获取“item-id”。
微软文档:https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http
这是我尝试过的:
尝试使用https://developer.microsoft.com/en-us/graph/graph-explorer 猜测可以让我下载所需文件的 api 链接。
我首先尝试像这样获取共享点站点:
https://graph.microsoft.com/v1.0/sites/omidtechnfr.sharepoint.com:/sites/delploy
成功了:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites/$entity",
"createdDateTime": "2021-07-15T21:02:02.78Z",
"description": "delploy",
"id": "omidtechnfr.sharepoint.com,5e03397e-03b0-4d92-9658-f9163f0131b3,1d9f21da-4d74-45db-b5d4-e4a7f7f278a1",
"lastModifiedDateTime": "2021-07-17T02:16:39Z",
"name": "delploy",
"webUrl": "https://omidtechnfr.sharepoint.com/sites/delploy",
"displayName": "delploy",
"root": {},
"siteCollection": {
"hostname": "omidtechnfr.sharepoint.com"
}
}
然后我尝试使用我认为是 SharePoint 网站 delploy 的项目 ID 来尝试从该网站获取更多信息,以便我可以尝试找到我想要下载的文件的 item-id :
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/
我得到了一些结果,但它没有让我对它做任何事情的 item-id:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2021-07-11T05:16:50Z",
"description": "",
"id": "b!fjkDXrADkk2WWPkWPwExs9ohnx10TdtFtdTkp_fyeKF_K1_Z49FFSbzXVFRA5GKa",
"lastModifiedDateTime": "2021-07-16T18:32:35Z",
"name": "Documents",
"webUrl": "https://omidtechnfr.sharepoint.com/sites/delploy/Shared%20Documents",
"driveType": "documentLibrary",
"createdBy": {
"user": {
"displayName": "System Account"
}
}
此时我开始变得绝望和有点生气。所以我试着从sharepoint下载文件,并假设下载链接末尾的字符是item-id,但这也不起作用:
下载链接:
https://omidtechnfr.sharepoint.com/sites/delploy/_layouts/15/download.aspx?UniqueId=25e2fd4f%2Deb32%2D43ac%2D9141%2Dfa47a610a27c
使用https://www.urldecoder.org/ 解码我假设是我要下载的文件的item-id
25e2fd4f-eb32-43ac-9141-fa47a610a27c
然后试图拼命地将它附加到 Microsoft graph api 上,看看会发生什么:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/items/25e2fd4f-eb32-43ac-9141-fa47a610a27c
它失败了:
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"date": "2021-07-17T14:13:51",
"request-id": "985e2893-5343-47ac-a93c-6629a00c4eb3",
"client-request-id": "73a3b6d0-f1ce-bb51-b126-43f0957d15e3"
}
}
}
【问题讨论】:
标签: sharepoint microsoft-graph-api