简体   繁体   English

使用 Microsoft Graph API 下载 Sharepoint 文件未显示内容属性

[英]Downloading Sharepoint File using Microsoft Graph API not showing content attribute

I'm trying to download a file from SharePoint online using Microsoft Graph API.我正在尝试使用 Microsoft Graph API 从 SharePoint Online 下载文件。 Graph API is not allowing me to use /Content. Graph API 不允许我使用 /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:当我尝试添加 /content 时,我得到:

{
"error": {
    "code": "BadRequest",
    "message": "Resource not found for the segment 'content'.",
    "innerError": {
        "request-id": "<ReqID>",
        "date": "<date>"
    }
}

} }

How do i download this file using the API?如何使用 API 下载此文件?

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端点https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}返回ListItem资源,ContentDriveItem资源的属性哪一个

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

to download a content 下载内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 sharepoint API 或 Microsoft Graph 从 sharepoint 站点上的文件夹请求文件内容? - How to request file content from a folder on a sharepoint site using sharepoint API or Microsoft Graph? 使用 Microsoft Graph API 更新与内容类型关联的 SharePoint 字段 - Update SharePoint fields associated with Content Type using Microsoft Graph API 使用“sourcedoc”ID从Microsoft Graph API下载SharePoint文件 - Download SharePoint file from Microsoft Graph API using “sourcedoc” ID 使用 Microsoft Graph 在线上传文件到 SharePoint API - Uploading a File to SharePoint Online using Microsoft Graph API 使用 Microsoft Graph API 从 SharePoint 在线获取文件 - Get a file from SharePoint Online using Microsoft Graph API Microsoft Graph Api 上传文件到 SharePoint - Microsoft Graph Api upload file to SharePoint 使用Microsoft Graph将文件上传到SharePoint驱动器 - Upload file to SharePoint drive using Microsoft Graph 如何使用 Microsoft Graph API 和 Graph Client 添加 SharePoint 选项卡? - How to add a SharePoint tab using Microsoft Graph API and Graph Client? 使用图 api 访问 Sharepoint 站点内容 - Acessing Sharepoint sites content using graph api 使用 Microsoft Graph API 将 Excel 文档在线上传到 SharePoint 时的 0 字节文件 - 0 Byte file when uploading an Excel document to SharePoint online using the Microsoft Graph API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM