问题
Currently we are getting all lists in all sub sites using below REST query.
'/_api/Web/Webs?$expand=Lists&select=Title,id,ParentWebUrl'
now we would like to get the all content types that are used in those lists as well. Tried expanding ContentTypes, but could not get it to work.
Can anyone help to get content types belong to those lists? Even if filtering by content type in the REST query it self is fine.
or is there any way to do this in search results of lists?
回答1:
After searching everywhere and getting no answers here, I've come to the conclusion there is no possibility of doing this way. So, I've used SharePoint Search services to get my results.
querytext = 'path:"your site collection path" AND (ContentClass:"STS_List_GenericList" OR ContentClass:"STS_List_DocumentLibrary")';
Later I decided to add listIDs to the query as I was getting ListIDs from previous Item search.
querytext = '(ListID:"Your list1 ID" OR ListID:"Your list2 ID" OR ListID:"Your listn ID")" AND (ContentClass:"STS_List_GenericList" OR ContentClass:"STS_List_DocumentLibrary")';
The issue was now if the list IDs exceed more than 75, the querytext max character exceeds and no results was received. After searching a way to increase the maximum limit and finding out there is no way to do it, I divided the list IDs into a set 75 IDs and send separate requests for each set, then combined all together. You can read it how it was done here Batch Search requests
来源:https://stackoverflow.com/questions/45025996/getting-sharepoint-list-content-types