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('')/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 库结构:

Assume the following Documents library structure:

Documents (library)
   |
   Guides (folder)
     |
     SharePoint User Guide.docx (file)

然后,以下请求:

/_api/web/lists/getbytitle('Documents')/items 将返回 2 个项目:

/_api/web/lists/getbytitle('Documents')/items will return 2 items:

  • Guides 文件夹关联的列表项
  • 与文件关联的列表项

同时请求:/_api/web/getFolderByServerRelativeUrl('Documents')/files

将返回 0 个文件,因为根文件夹中不包含任何文件

will returns 0 files since there are no files contained in the root folder

但是提供文件夹网址的请求:/_api/web/getFolderByServerRelativeUrl('Documents/Guides')/files

but the request with provided folder url: /_api/web/getFolderByServerRelativeUrl('Documents/Guides')/files

将返回 SharePoint User Guide.docx 文件.