7

There are five Custom Lists in a site collection, all have same content type. I would like to get all items from those five lists using rest api. Is there a way to get all items from all lists having a specific content type using rest api?

  • I would love to have your snippet! – bgmCoder Jul 25 '17 at 22:15
13

Yes, you can query search using the REST API with the following URL to get list items specific to a content type:

http://yoursite.domain.com/_api/search/query?querytext='contenttype:CONTENT_TYPE_NAME'

To find out more about search using REST see this and this links.

  • 1
    To add to this, it may be easier to create a result source, and simply use the sourceid parameter: https://<site>/_api/search/query?sourceid='xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'. This will allow you to test your query before messing with code. – wjervis Sep 22 '14 at 11:33
  • 1
    I sued your solution in the browser but I got this web page can not be displayed – Medes Sep 22 '14 at 12:15
  • Do you have crawled content in your search index ? You can check it by querying into the default seach box in the site to make sure that search is returning the results. You can try to change the browser settings to see if the REST query used in browser returns the results. Check this. Also, to test the rest query for content type try querying 'contenttype=ITEM' to see if the search works. – Vipul Kelkar Sep 22 '14 at 12:25
  • Sorry about my mistake, I tested it on my Online dev environment and it works, it seems my VM have some problem regarding crawling and search becasue search not works at all. I get no result when I search – Medes Sep 22 '14 at 12:37
  • I get undefined as the return, even when I search for ITEM – bgmCoder Jul 26 '17 at 22:34

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.