使用 Microsoft Graph API 下载 Sharepoint 文件不显示内容属性 [英] Downloading Sharepoint File using Microsoft Graph API not showing content attribute
问题描述
我正在尝试使用 Microsoft Graph API 从 SharePoint 在线下载文件.Graph API 不允许我使用/Content.
I'm trying to download a file from SharePoint online using Microsoft Graph API. Graph API is not allowing me to use /Content.
这是我正在使用的端点:
This is the endpoint I'm using:
https://graph.microsoft.com/v1.0/sites/<host.sharepoint.com>/lists/<ListID>/items/<ItemID>
这是得到的(删除的值):
This is what get (Values Removed):
{
"@odata.context","@odata.etag","createdDateTime","eTag","id","lastModifiedDateTime","webUrl","createdBy"{"user": {"email","id","displayName"}}, "lastModifiedBy": {"user": {"email","id","displayName"}},
"parentReference": {"id"},
"contentType": {"id"},
"fields@odata.context",
"fields": {"@odata.etag","FileLeafRef","id","ContentType","Created", "AuthorLookupId","Modified","EditorLookupId","_CheckinComment", "LinkFilenameNoMenu","LinkFilename","DocIcon","FileSizeDisplay", "ItemChildCount","FolderChildCount","_ComplianceFlags","_ComplianceTag", "_ComplianceTagWrittenTime","_ComplianceTagUserId","_CommentCount", "_LikeCount","Edit","_UIVersionString","ParentVersionStringLookupId", "ParentLeafNameLookupId"
}
}
当我尝试添加/内容时,我得到:
When i try to add /content i get:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'content'.",
"innerError": {
"request-id": "<ReqID>",
"date": "<date>"
}
}
}
如何使用 API 下载此文件?
How do i download this file using the API?
推荐答案
端点https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}
返回 ListItem
资源 但 Content
是 DriveItem
资源 其中
The endpoint https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}
returns ListItem
resource but Content
is a property of DriveItem
resource which
表示驱动器中的项目,例如文档、照片、视频或文件夹资源
Represents an item within a drive, like a document, photo, video, or folder resource
这就是发生此错误的原因.
that's the reason this error occurs.
鉴于提供的端点,它可以修改为
Given the provided endpoint it could be modified to
GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem/content
到 下载内容
这篇关于使用 Microsoft Graph API 下载 Sharepoint 文件不显示内容属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!