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.
    – MattWolc24
    Jul 5, 2022 at 16:05
  • what error you are getting? Jul 6, 2022 at 13:47
0

You can expand files and folders by following rest api

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.