我查看了有关此问题的文档,并努力了解 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/