1

I am new to Sharepoint. I discovered that Sharepoint 2013 and later supports the REST interface. I was trying to query the REST API to find all the document libraries under a given site.

I tried GET /_api/web/lists/ HTTP/1.1

But in the results how do I find which one is a document library? I suspected that the BaseTemplate property could be used to see which one is document library but unfortunately, I see there are folders like Form Templates, Site Assets, Style Library also have the same BaseTemplate value (101) as the actual document libraries (e.g. Shared Documents).

2

This is what you need to use: <your_site_url>/_api/Web/Lists?$filter=BaseTemplate eq 101.

The base template 101 is for document libraries. For other types of lists, check the base templates here: https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.listtemplatetype.aspx


There is no built-in functionality to get only the libraries created manually by users. There is a way which may not be 100% perfect depending on your scenario. I am talking about filtering out the libraries you don't need by specifying their titles: <your_site_url>/_api/Web/Lists?$filter=BaseTemplate eq 101 and Title ne 'Site Assets' and Title ne 'Style Library'.

Although this works, it is not ideal when other libraries get created by SharePoint. For example, if in the future you enable the "Content Organizer" then SharePoint will automatically create a new library called "Drop off Library".

  • Right. I tried using this, and it is helpful. Although I see Form Library, Site Assets and Style Library along with the document libraries. I haven't added these but maybe SharePoint added them. I was thinking if there was a way to get only the document libraries I added and the one by default (called 'Shared Documents' or Documents) – Puneet Jul 15 '16 at 2:25
  • Yes, the Site Assests and Shared Documents libraries are created by SharePoint when you create new team sites. Style Library is created by SharePoint when you enable the Publishing feature on the site. I will update my answer to show how to get all libraries created manually by users. – Mihail-Florin Popa Jul 15 '16 at 10:07
  • Unfortunately, with REST (as I just tested) you cannot filter based on the "Author" - the user who created the library, which might have been more helpful, maybe. What exactly are you developing? Is it a JS solution, a C# solution? Why do you need only specific libraries? – Mihail-Florin Popa Jul 15 '16 at 10:32
  • Thanks for your reply Mihail. I am developing a Java solution, which would look for documents under a document library, download them, do something and upload them again. Hence I would need to get the URLs of document libraries like 'Shared Documents' and the ones user have created. I don't think I need the Style Library and Site Assets and Form library. – Puneet Jul 18 '16 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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