![](/img/trans.png)
[英]How to request file content from a folder on a sharepoint site using sharepoint API or Microsoft Graph?
[英]Downloading Sharepoint File using Microsoft Graph API not showing content attribute
我正在嘗試使用 Microsoft Graph API 從 SharePoint Online 下載文件。 Graph API 不允許我使用 /Content。
這是我正在使用的端點:
https://graph.microsoft.com/v1.0/sites/<host.sharepoint.com>/lists/<ListID>/items/<ItemID>
這就是得到(值已刪除):
{
"@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"
}
}
當我嘗試添加 /content 時,我得到:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'content'.",
"innerError": {
"request-id": "<ReqID>",
"date": "<date>"
}
}
}
如何使用 API 下載此文件?
端點https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}
返回ListItem
資源,但Content
是DriveItem
資源的屬性哪一個
表示驅動器中的項目,如文檔、照片、視頻或文件夾資源
這就是發生此錯誤的原因。
鑒於提供的端點,它可以修改為
GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem/content
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.