javascript 检索所有文件名的 SharePoint 2013 库。REST API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21012362/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SharePoint 2013 Library retrieving all file names. REST API
提问by chandings
I have a library on Sharepoint 2013 and retrieving all the parameters (using angularjs on the client side.) using the following code.
我在 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);
});
However the result does not contain the file name or file url. I need to create an anchor link to the file. It does contain the custom parameters that I have added to the List/Lib.
但是结果不包含文件名或文件 url。我需要创建指向该文件的锚链接。它确实包含我添加到列表/库中的自定义参数。
I have never worked with SharePoint before. The client code is a snippet of an angularjs factory and it is working (as far as js is concerened).
我以前从未使用过 SharePoint。客户端代码是 angularjs 工厂的一个片段,它正在工作(就 js 而言)。
I do not want to make another restcall using d.result[index].File.__deffered.uri
and then open the document in a new blank window.
我不想使用d.result[index].File.__deffered.uri
然后在新的空白窗口中打开文档进行另一个休息调用。
Thanks for your help.
谢谢你的帮助。
回答by prawn
Try the
试试
FileLeafRef
文件叶引用
in your url
在你的网址
site/_api/web/lists/getByTitle('LibraryName')/items?$top=1000&$select=FileLeafRef
回答by Vadim Gremyachev
How to retrieve file name using SharePoint REST
如何使用 SharePoint REST 检索文件名
Option 1
选项1
Via FileLeafRef
List Item property
通过FileLeafRef
列表项属性
REST endpoint:
REST 端点:
/_api/web/lists/getByTitle('<list title>')/items?$select=FileLeafRef
Option 2
选项 2
Via File
Name
property:
通过File
Name
财产:
REST endpoint:
REST 端点:
/_api/web/lists/getByTitle('<list title>')/items?$select=File/Name&$expand=File