I have a library on Sharepoint 2013 and retrieving all the parameters (using angularjs on the client side.) using the following code.
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.
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).
I do not want to make another rest call using d.result[index].File.__deffered.uri
and then open the document in a new blank window.
Thanks for your help.
I have a library on Sharepoint 2013 and retrieving all the parameters (using angularjs on the client side.) using the following code.
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.
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).
I do not want to make another rest call using d.result[index].File.__deffered.uri
and then open the document in a new blank window.
Thanks for your help.
Share Improve this question edited Jan 9, 2014 at 6:46 chandings asked Jan 9, 2014 at 5:38 chandingschandings 5493 gold badges9 silver badges23 bronze badges 1- Try asking over at sharepoint.stackexchange.com – joweiser Commented Jan 20, 2014 at 17:46
2 Answers
Reset to default 11Try the
FileLeafRef
in your url
site/_api/web/lists/getByTitle('LibraryName')/items?$top=1000&$select=FileLeafRef
How to retrieve file name using SharePoint REST
Option 1
Via FileLeafRef
List Item property
REST endpoint:
/_api/web/lists/getByTitle('<list title>')/items?$select=FileLeafRef
Option 2
Via File
Name
property:
REST endpoint:
/_api/web/lists/getByTitle('<list title>')/items?$select=File/Name&$expand=File