1

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

1 Answer 1

1

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:

Working with folders and files with REST.

14
  • Hi Ganesh i need list of all documents in a particular folder. I have tried these properties but no success. The first two will provide a particular file and the later one is giving me null response. Commented Jul 12, 2019 at 7:57
  • Sorry, it was my mistake. I got the documents list, passing incorrect library name. Commented Jul 12, 2019 at 8:00
  • Could you please help as, how to save these document names using Rest API Commented Jul 12, 2019 at 8:00
  • Where do you want to save this names? Commented Jul 12, 2019 at 8:08
  • We have a website, hitting this endpoint the list of document should be shown on that portal, only name I need. Commented Jul 12, 2019 at 8:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.