SharePoint 2013 Library检索所有文件名.REST API

cha*_*ngs 6 javascript rest sharepoint sharepointdocumentlibrary

我在Sharepoint 2013上有一个库,并使用以下代码检索所有参数(在客户端使用angularjs.).

var spListURL = siteURL + "_api/lists/getByTitle%28%27" + docLibName + "%27%29/items";
$http.get(spListURL,
{ headers: {"Accept": "application/json; odata=verbose", } }).success(function (result) {
    dfd.resolve(result);
})
.error(function (data, status, headers, config) {
    errorFactory.buildError(data, status, headers, ORIGIN_VIEW_NAME);
});
Run Code Online (Sandbox Code Playgroud)

但是,结果不包含文件名或文件URL.我需要创建一个指向该文件的锚链接.它确实包含我添加到List/Lib的自定义参数.

我之前从未使用过SharePoint.客户端代码是angularjs工厂的片段,它正在工作(就js而言是可以理解的).

不想再使用一个休息呼叫d.result[index].File.__deffered.uri,然后在一个新的空白窗口中打开文档.

谢谢你的帮助.

pra*_*awn 10

试试吧

FileLeafRef

在你的网址中

site/_api/web/lists/getByTitle('LibraryName')/items?$top=1000&$select=FileLeafRef
Run Code Online (Sandbox Code Playgroud)


Vad*_*hev 9

如何使用SharePoint REST检索文件名

选项1

通过FileLeafRef列表项属性

REST端点:

/_api/web/lists/getByTitle('<list title>')/items?$select=FileLeafRef
Run Code Online (Sandbox Code Playgroud)

选项2

通过File Name财产:

REST端点:

/_api/web/lists/getByTitle('<list title>')/items?$select=File/Name&$expand=File
Run Code Online (Sandbox Code Playgroud)