1

I am trying to retrieve a list of documents in our document library using the API. I do a GET call to https://mysite.sharepoint.com/sites/RapidMachiningSolutionsLLC/_api/Web/Lists/getbytitle('myDocLibrary')/items, but the data that I receive is only for the .doc files in the library.

2 Answers 2

0

There are multiple ways to retrieve files from the Document library.

Using the REST API you have used, we need to add select and expand in the query as below.

/sites/RapidMachiningSolutionsLLC/_api/Web/Lists/getbytitle('myDocLibrary')/items?$select=EncodedAbsUrl,*,File/Name&$expand=File

Another approach is to use GetFolderByServerRelativeUrl method to get all the files.

/sites/RapidMachiningSolutionsLLC/_api/web/GetFolderByServerRelativeUrl('/myDocLibrary')/Files

Make sure you are using the INTERNAL NAME of your document library.

2
  • The first query you showed still does not include .docx or .xlsx files. I haven't been able to get GetFolderByServerRelativeUrl to work. Commented Jul 5, 2022 at 16:05
  • what error you are getting? Commented Jul 6, 2022 at 13:47
0

You can expand files and folders by following rest api

/_api/web/GetFolderByServerRelativeUrl('folderUrl')?$expand=Folders,Files

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.