Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get file name from Sharepoint Asset Library

How can I get the file name of an image from a SharePoint 2013 Asset Library?

I am trying to write a JQuery/REST snippet to search a subset of images within the library, based on their other column values and display them. I would use FileLeafRef in case of a Document Library, but I couldn't find an equivalent field in Asset Library.

I so far tried the following, neither returns file name: https:///crm/_api/Web/Lists/GetByTitle('Publication%20List')/items?select=File/Name&expand=File https:///crm/_api/Web/Lists/GetByTitle('Publication%20List')/items?select=FileLeafRef

like image 887
Charles Avatar asked Nov 29 '25 23:11

Charles


1 Answers

There is a typo in your example, in particular $ symbol is missing for $select and $expand query options (more details).

The following rest endpoints demonstrate how to retrieve file name from Assets library:

1) Using FileLeafRef property:

/_api/web/lists/getByTitle('<list title>')/items?$select=FileLeafRef

2) Using File/Name property:

/_api/web/lists/getbytitle('<list title>')/items?$select=File/Name&$expand=File

3) Using Folder/Files property:

/_api/web/getfolderbyserverrelativeurl('<list url>')/files?$select=Name  
like image 97
Vadim Gremyachev Avatar answered Dec 01 '25 14:12

Vadim Gremyachev