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

时间:2019-02-19 15:35:53

标签: sharepoint postman microsoft-graph sharepoint-online

我正在尝试使用Microsoft Graph API从SharePoint在线下载文件。 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​​下载此文件?

1 个答案:

答案 0 :(得分:0)

端点https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}返回ListItem resource,但是ContentDriveItem resource的属性

  

代表驱动器中的项目,例如文档,照片,视频或   文件夹资源

这就是发生此错误的原因。

鉴于提供的端点,可以将其修改为

GET https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items/{item-id}/driveItem/content

download a content