java - 微软图形API : A question about IDriveItemCollectionPage

标签 java microsoft-graph-api

我查看了有关此问题的文档,并努力了解 IDriveItemCollectionPage 的工作原理。

我目前正在执行以下操作,尝试使用 Java SDK 列出给定其驱动器 ID 的站点根驱动器的所有子 DriveItems

    public ArrayList<DriveItem> getDriveItemChildrenFoldersOfRootDrive(String rootDriveId){
    //gets the children folder driveI
    IDriveItemCollectionPage driveChildren= mGraphServiceClient.drives().byId(rootDriveId).root().children().buildRequest().get();
    ArrayList<DriveItem> results = new ArrayList<DriveItem>();
    results.addAll(driveChildren.getCurrentPage());
    return results;
}

我意识到如果 getNextPage 返回 null 则不再有结果,但是如果有的话,您是否必须进行另一个 api 调用才能获取下一页?如何使用上述设置来做到这一点?

最佳答案

同意布拉德的观点。我在我身边测试并获得了成功。这是我的代码

public static void main(String[] args) {
    IGraphServiceClient client = GetClient();
    IDriveCollectionPage page = client.drives().buildRequest().get();
    List<Drive> drives = page.getCurrentPage();

    while(page.getNextPage() != null){
        page = page.getNextPage().buildRequest().get();
        drives.addAll(page.getCurrentPage());
    }

    System.out.println(drives.size());
}

关于java - 微软图形API : A question about IDriveItemCollectionPage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57043233/

相关文章:

java - 让容器使用OpenJDK和现有容器的库

java - 以文件名作为参数执行 jar 文件

microsoft-graph-api - Microsoft Graph FindMeetingTimes 差距

microsoft-graph-api - 使用 Microsoft Graph 客户端库更新联系人

microsoft-graph-api - 使用 Action.OpenUrl 从自适应卡打开任务模块

azure - 通过 MS Graph Explorer 更新 Azure AD 应用程序 appRoles

java - 单例和异常

java - 使用 DB2 驱动程序访问 as400

java - Maven 上最新版本的 MapReduce 库

microsoft-graph-api - 如何知道收件箱是哪个mailFolder?