递归扩展OneDrive图API中的子节点



我想获得OneDrive中文件夹的所有内容。文件夹中有子文件夹,子文件夹中有子文件夹,例如:

Parent/
└── Child1/
├── Child1.1/
│   ├── File1.1.1
│   └── File1.1.2
└── Child1.2/
├── File1.2.1
└── File1.2.2

我想保持关于文件夹层次结构的知识,基本上类似于Parent/Child1/File1.1.1,所以我不能使用这里引用的空查询图搜索方法,它以平面格式返回所有内容,没有任何关于层次结构的信息。

我可以一个一个地递归地调用每个文件夹,但那将会很多,因为在父目录中有数千个文件夹。

根据文档(这里也是),我希望expand=children参数能够工作,但似乎没有。什么好主意吗?

GET https://graph.microsoft.com/v1.0/me/drive/items/<id>/children?$expand=children
{
"error": {
"code": "notSupported",
"message": "Operation not supported",
"innerError": {
"date": "2022-12-17T17:03:28",
"request-id": "",
"client-request-id": ""
}
}
}

使用此url获取儿童列表,我已将链接粘贴在下面。

GET https://graph.microsoft.com/v1.0/me/drive/items/<id>?expand=children

最新更新