[英]obtain item-id for microsoft graph api
I am trying to figure out how to obtain an "item-id" for a file in a sharepoint site for microsoft graph API.我想弄清楚如何为 Microsoft 图形 API 的共享点站点中的文件获取“项目 ID”。
Microsoft documentation: https://docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http微软文档: https : //docs.microsoft.com/en-us/graph/api/driveitem-get?view=graph-rest-1.0&tabs=http
Here is what I tried for far:这是我迄今为止尝试过的:
Tried using https://developer.microsoft.com/en-us/graph/graph-explorer to guess the api link that will let me download the file I want.尝试使用https://developer.microsoft.com/en-us/graph/graph-explorer猜测可以让我下载我想要的文件的 api 链接。
I first tried to get the sharepointsite like so:我首先尝试像这样获取 sharepointsite:
https://graph.microsoft.com/v1.0/sites/omidtechnfr.sharepoint.com:/sites/delploy
That worked:那有效:
{
"@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"
}
}
So then I tried using what I ASSUME is the item-id for the SharePoint site delploy
to try and get more information out of the site so I can try to find the item-id
for the file I want to download:然后我尝试使用我假设是 SharePoint 站点
delploy
的 item-id 来尝试从站点中获取更多信息,以便我可以尝试找到我要下载的文件的item-id
:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/
And I got back some result but it doesn't so the item-id for me to do anything with it:我得到了一些结果,但它并没有让我可以用它做任何事情:
{
"@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"
}
}
At this point I started to get desperate and a little angry.这时,我开始变得绝望和有点生气。 So I tried to just download the file from sharepoint and assume that the characters at the end of the download link was the
item-id
but that didn't work either: download link:所以我试图从 sharepoint 下载文件,并假设下载链接末尾的字符是
item-id
但这也不起作用:下载链接:
https://omidtechnfr.sharepoint.com/sites/delploy/_layouts/15/download.aspx?UniqueId=25e2fd4f%2Deb32%2D43ac%2D9141%2Dfa47a610a27c
Used https://www.urldecoder.org/ to decode what I am assuming is the item-id for the file I want to download使用https://www.urldecoder.org/解码我假设是我要下载的文件的项目 ID
25e2fd4f-eb32-43ac-9141-fa47a610a27c
Then tried to desperately tack this on to the Microsoft graph api to see what happens:然后尝试拼命将其添加到 Microsoft 图形 API 上,看看会发生什么:
https://graph.microsoft.com/v1.0/sites/5e03397e-03b0-4d92-9658-f9163f0131b3/drive/items/25e2fd4f-eb32-43ac-9141-fa47a610a27c
and it failed:它失败了:
{
"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"
}
}
}
You could get the file by the path: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
您可以通过路径获取文件:
https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
/ https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
path https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/{item-path}
For example: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
例如:
https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/test.docx
If the file is in a folder, it would be like this: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx
如果文件在一个文件夹中,它会是这样的:
https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx
: https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root:/folder1/test.docx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.