2

We are working on a mobile app where we want to get all the custom lists (created by user etc.).

API GET "/_api/web/lists/" is working perfectly fine but it is returning all the lists available in site collection, including the ones like "Style Library", "TaxonomyHiddenList", "wfpub" etc.

Is there any way to get custom lists created by users only?

3

One property you can start to filter by is IsCatalog. Another one you can use is Hidden, although you are likely to use this on your own lists.

E.g.,

/_api/Web/Lists/?$filter=IsCatalog eq false
/_api/Web/Lists/?$filter=Hidden eq false

Update

Filtering out all lists seems a bit tricky, as for instance the user information list doesn't seem to have much information to filter by, except BaseType and ListItemEntityTypeFullName, but that would end up with a huge set of types to filter by (can't filter by lt or gt as one could use say BaseTemplate 101 (doclib), and 200 (Meetings) while not wanting 112 (User information list)).

But perhaps another hack can be used, at least to narrow it down a little bit more, as it turns out User information list is located in _catalogs, despite not being flagged as IsCatalog. So we could filter out all those lists, like this:

$expand=RootFolder
&$filter=not(substringof('/_catalogs/',RootFolder/ServerRelativeUrl)) 
  and IsCatalog eq false
  • This works but only hides few lists. It's showing User Information List as well. IsHidden will also not hide some lists created by the system. So not fully accurate :) – Akhoy Sep 13 '15 at 14:11
  • @Akhoy I updated the answer. Feel it is not the correct approach, but for some parts it does seem to work – eirikb Sep 13 '15 at 14:44
  • Is returning all the lists expected behavior by API? The problem is, I am trying to show user the lists on his / her mobile phone where he can select a list and upload his photos to that particular list. – Rahul Patil Sep 14 '15 at 3:25
  • @rahul-patil is the default yes, I think it would be bad if the API was hiding elements based on "friendlyness". If you want lists for uploading you probably want document libraries, to get only libraries try $filter=BaseType eq 1. To only get document libraries specifically try $filter=BaseTemplate eq 101, but you'd also want libraries such as Picture library, which is 109. Catalogs are libraries, so you should probably combine with my filter above – eirikb Sep 14 '15 at 5:30
0

When just looking for lists, I found a combination of Hidden and BaseType gave me the best results.

/_api/web/lists?$filter=Hidden eq false and BaseType ne 1

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.