Is it possible to get a list of all content types in a site collection using search api?

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/244634

  •  19-01-2021
  •  | 
  •  

Question

I have a few site collections and I would like to retrieve the content types of each site collection and display them as a list and I was wondering if it can be achieved using search api?

Était-ce utile?

La solution

only in a very convulted way... Search is not indexing contenttypes as objects.

You would need to pull all items from the Sitecollection and iterate over them, extracting all contenttypes. Which would not help you at all, since there is no info about them in the result (besides names and ID's)

The proper solution would be to pull them from the REST Service under the URL

/teams/yourSite/_api/Web/ContentTypes

Autres conseils

No, it cannot be done. If a content type does not have any data associated with it, the search index will never know it exists.

There are other ways to do it, but Search is not the right tool for this job.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top