我正在尝试使用Microsoft Graph API从SharePoint文档库获取文件夹和文档。
如果我对https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MyDocumentSite:/drives/执行GET请求,我会得到如下结果:
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value":[
        {
            "createdDateTime": "2019-09-05T07:09:49Z",
            "description": "",
            "id": "b!wxh2ZWwoT0KKTdLRYjD5jvzjo8jkat5LgY3VyfgEqkv3YVg_XXXXXXXXXXXXXXXX",
            "lastModifiedDateTime": "2019-09-05T07:09:49Z",
            "name": "Documents",
            "webUrl": "https://mysite.sharepoint.com/sites/MyDocumentSite/Shared%20Documents",
            "driveType": "documentLibrary",
            "createdBy":{"user":{"displayName": "System Account" }},
            "lastModifiedBy":{"user":{"email": "me@myorganization.org", "id": "73f9990c-5c92-4839-8b13-XXXXXXXXXXXX", "displayName": "John Smith"…},
            "quota":{"deleted": 0, "remaining": 0, "total": 0, "used": 0}
        }
    ]
}但是,如果我试图通过对该id:https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MyDocumentSite:/drives/b!wxh2ZWwoT0KKTdLRYjD5jvzjo8jkat5LgY3VyfgEqkv3YVg_XXXXXXXXXXXXXXXX执行GET请求来访问该驱动器,则会得到一个BadRequest错误:
{
    "error":{
        "code": "BadRequest",
        "message": "Url specified is invalid.",
        "innerError":{
            "request-id": "7c9eaf61-764f-4d72-abdb-ffa2fe868e90",
            "date": "2019-09-16T19:09:41"
        }
    }
}最终,我想要一种方法来显示文档库中的所有文件夹和文档,但我似乎无法完成这一初始步骤。
发布于 2019-09-18 21:41:54
实际上,当站点由site path寻址时,以下查询将失败,并出现异常:
GET `https://graph.microsoft.com/v1.0/sites/{hostname}:/{server-relative-path}/drive/root/children` 这似乎是一个错误,因为类似的查询,但当站点为addressed by id时,工作如预期:
GET https://graph.microsoft.com/v1.0/sites/{site-id}/drive/root/children另一个需要考虑的选项是,通过标识符获取Drive资源(不指定站点路径或标识符),例如:
GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root/children当轮到获取库中的所有文档和文件夹时,List children of a driveItem endpoint仅返回当前文件夹下的1级。
要退还所有驱动器项目,您至少可以考虑:
例如,通过List children of a driveItem endpoint遍历文件夹结构GET https://graph.microsoft.com/v1.0/drives/{drive-id}/root/search(q='')
search method发布于 2019-09-17 04:53:21
使用“增量”接口:https://docs.microsoft.com/en-us/graph/api/driveitem-delta?view=graph-rest-1.0&tabs=http
第一次调用将返回所有项。(如果有分页功能,则需要调用nextLink,直到收到deltaLink为止)。
您可能希望使用GET /sites/{siteId}/drive/root/delta或GET /drives/{drive-id}/root/delta
发布于 2019-10-05 03:33:44
获得想要查询的驱动器id后,使用根目录下的/drives发出请求:
https://graph.microsoft.com/v1.0/drives/<driveId>https://stackoverflow.com/questions/57963101
复制相似问题