获取 Microsoft 图表的项目 ID api
obtain item-id for microsoft graph api
我正在尝试弄清楚如何在 Microsoft Graph 的共享点站点中获取文件的“项目 ID”API。
微软文档: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 link 让我下载我想要的文件。
我第一次尝试像这样获取共享点站点:
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/
我得到了一些结果,但它并没有让我用它做任何事情的项目 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"
}
}
此时我开始感到绝望和愤怒。所以我试着从共享点下载文件并假设下载结束时的字符 link 是 item-id
但这也不起作用:
下载 link:
https://omidtechnfr.sharepoint.com/sites/delploy/_layouts/15/download.aspx?UniqueId=25e2fd4f%2Deb32%2D43ac%2D9141%2Dfa47a610a27c
使用 https://www.urldecoder.org/ 解码我假设是我要下载的文件的项目 ID
25e2fd4f-eb32-43ac-9141-fa47a610a27c
然后尝试拼命将其添加到 Microsoft 图上 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"
}
}
}
您可以通过路径获取文件:https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
例如:https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
如果文件在文件夹中,会是这样:https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx
我正在尝试弄清楚如何在 Microsoft Graph 的共享点站点中获取文件的“项目 ID”API。
微软文档: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 link 让我下载我想要的文件。
我第一次尝试像这样获取共享点站点:
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/
我得到了一些结果,但它并没有让我用它做任何事情的项目 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"
}
}
此时我开始感到绝望和愤怒。所以我试着从共享点下载文件并假设下载结束时的字符 link 是 item-id
但这也不起作用:
下载 link:
https://omidtechnfr.sharepoint.com/sites/delploy/_layouts/15/download.aspx?UniqueId=25e2fd4f%2Deb32%2D43ac%2D9141%2Dfa47a610a27c
使用 https://www.urldecoder.org/ 解码我假设是我要下载的文件的项目 ID
25e2fd4f-eb32-43ac-9141-fa47a610a27c
然后尝试拼命将其添加到 Microsoft 图上 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"
}
}
}
您可以通过路径获取文件:https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
例如:https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
如果文件在文件夹中,会是这样:https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx