How to get document names inside a folder in sharepoint document Library?
题
I have a document Library in which there are a number of different folders. Each folder contain different documents. I need to fetch the name of all the documents in a particular folder. So far I have created the endpoint URL that is:
https:// Sharepointsite/sites/DeveloperSite/_api/web/GetFileByServerRelativeUrl('folderrelativeUrl')/Files
This URL gives me null result even if files are present in the folder. When I remove the folder name from URL and put folderRelativeUrl
till document Library, I got the result of all the document and files in that library.
I am using c# REST API in visual studio and I am not sure as how to get the name of the documents.
Can anyone provide some information regarding this?
It will be a great help.
Thanks
解决方案
Try below endpoints and see which suits best for your use:
1) Using FileLeafRef
property:
/_api/web/lists/getByTitle('<library title>')/items?$select=FileLeafRef
2) Using File/Name
property:
/_api/web/lists/getbytitle('<library title>')/items?$select=File/Name&$expand=File
3) Using Folder/Files
property:
/_api/web/GetFileByServerRelativeUrl('<folderrelativeUrl>')/files?$select=Name
Additional Reference: