SharePoint REST API getFolderByServerRelativeUrl不返回任何内容
我想先钻入库,然后钻入指定的文件夹,但是我在获取'getFolderByServerRelativeUrl'来为我抓取任何东西时遇到问题.
I would like to drill into the library and then into a specified folder, but I am having problems getting 'getFolderByServerRelativeUrl' to grab anything for me.
此http://_base/_api/web/getFolderByServerRelativeUrl('LibName')/files
返回零结果.但是,如果我使用http://_base/_api/web/lists/getbytitle('LibName')/items
,它将返回多个项目.
This http://_base/_api/web/getFolderByServerRelativeUrl('LibName')/files
returns zero results. But if I use http://_base/_api/web/lists/getbytitle('LibName')/items
it returns multiple items.
/_api/web/lists/getbytitle('<list title>')/items
端点返回库中的 all 列表项,/_api/web/getFolderByServerRelativeUrl('<url>')/files
仅返回位于(一级仅在下方)指定文件夹.
/_api/web/lists/getbytitle('<list title>')/items
endpoint returns all list items within a library, /_api/web/getFolderByServerRelativeUrl('<url>')/files
returns only files located under (one level beneath only) the specified folder.
示例
假定以下文档库结构:
Documents (library)
|
Guides (folder)
|
SharePoint User Guide.docx (file)
然后,发出以下请求:
/_api/web/lists/getbytitle('Documents')/items
将返回2个项目:
- 与
Guides
文件夹关联的列表项 - 与文件关联的列表项
- list item associated with
Guides
folder - list item associated with file
同时,请求:/_api/web/getFolderByServerRelativeUrl('Documents')/files
将返回0
文件,因为根文件夹中没有文件
will returns 0
files since there are no files contained in the root folder
但是带有提供的文件夹URL的请求:
/_api/web/getFolderByServerRelativeUrl('Documents/Guides')/files
but the request with provided folder url:
/_api/web/getFolderByServerRelativeUrl('Documents/Guides')/files
将返回SharePoint User Guide.docx
文件.