在一个drive pro(sharepoint)rest api中获取文件夹的文件夹

在一个drive pro(sharepoint)rest api中获取文件夹的文件夹,rest,sharepoint,onedrive,Rest,Sharepoint,Onedrive,我正在尝试使用sharepoint rest api获取文档文件夹下的文件夹列表。这看起来应该很简单,但我很难从文档中看到如何做到这一点 我想确定以下文件夹是否存在: [https]://[Site]/personal/[Path to User]/Documents/test 我试过: [https]://[Site]/\u api/web/GetFolderByServerRelativeUrl(“/Documents”) 给出“未找到文件”,我希望返回一些json,以提供文件信息等,如何确

我正在尝试使用sharepoint rest api获取文档文件夹下的文件夹列表。这看起来应该很简单,但我很难从文档中看到如何做到这一点

我想确定以下文件夹是否存在:

[https]://[Site]/personal/[Path to User]/Documents/test

我试过:

[https]://[Site]/\u api/web/GetFolderByServerRelativeUrl(“/Documents”)


给出“未找到文件”,我希望返回一些json,以提供文件信息等,如何确定/Documents/test文件夹是否已使用rest api创建?

请检查您的url是否有效,就像检查文档库的url一样:

[https]://[Site]/Documents
在您的情况下,如果其文档库:

[https]://[Site]/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')
或者写下URL的完整相对路径,如

[https]://[Site]/_api/web/GetFolderByServerRelativeUrl('/personal/[Path to User]/Documents/test')

我相信你应该这样尝试:

[https]://[Site]/\u api/web/GetFolderByServerRelativeUrl('Documents')/folders

这将给出文档库下所有文件夹的列表

希望这有帮助

接受指定文件夹的服务器相对URL的
serverRelativeUrl
参数

例子

地点:

[https]://[Site]/personal/[Path to User]/Documents
以下REST请求返回文件夹对象:

[https]://[Site]/personal/[Path to User]/_api/web/GetFolderByServerRelativeUrl('/personal/[Path to User]/Documents')

注意:指定了文档库的相对Url(不像示例中那样以
/
开头)


我可以向该端点发出请求:[https]://[Site]/\u api/web/folders并返回信息,但即使是像[https]://[Site]/\u api/web/GetFolderByServerRelativeUrl('/personal')这样简单的东西,我也无法获得任何信息,我得到所有这些的文件未找到异常,包括[https]://[Site]/\u api/web/GetFolderByServerRelativeUrl(“/Shared%20Documents”)您能够使用相同的凭据登录到同一浏览器上的站点吗?您是否尝试了[https]://[site]/_api/web/GetFolderByServerRelativeUrl(个人/[Path to User]/Documents]);
[https]://[Site]/personal/[Path to User]/_api/web/GetFolderByServerRelativeUrl('Documents')