Need total count while fetching the resources from OneDrive

时间:2017-05-16 09:25:42

标签: office365 microsoft-graph onedrive

As per the specs, we can get a maximum of 200 item when we retrieve the list of files and folders from OneDrive(Personal or Business) along with the NextPageLink. However, I also need to get the total count of files available while getting the list of files and folders from:

1.) Root
2.) Shared With Me
3.) Inside the DriveItem
4.) Search

How can I achieve this?

When I make the below calls using Microsoft Graph SDK, I get "Count" field which returns the count of items in the returned list:

var response = await client.Me.Drive.Root.Children.Request().GetAsync();
var sharedWithMe = await client.Me.Drive.SharedWithMe().Request().GetAsync();

However, I also need the total count of items to be displayed. Is this possible?

1 个答案:

答案 0 :(得分:1)

从所有这些来源获取文件/文件夹列表时,无法获得总项目数。

您可以向/ drive / root对象发出请求,该对象将返回根目录下直接包含的项目数:

GET https://graph.microsoft.com/v1.0/me/drive/root

{
    "name": "root",
    "folder": {
        "childCount": 7
    },
    "root": {},
    "size": 51242712
}

截断结果,但是您可以看到folder.childCount == 7中有7个项目。此属性可用于任何文件夹,因此如果您枚举文件夹的内容,则可以查询文件夹本身得到一个近似的项目数(当你翻阅文件夹中的项目时,计数可能会改变)。

我们今天没有任何可用于与我共享或搜索结果的内容。在使用api.onedrive.com端点进行搜索时,OneDrive个人会返回搜索结果的大致项目数,但Microsoft Graph或OneDrive for Business中尚未提供此项目。