I am on SharePoint Online environment, where i have a site(Lets call it Site A) https://xxxxx.com/sites/sitecollection/SiteA and multiple sub sites under Site A (Subsite B, Subsite C, Subsite D and so on....). The subsites are added every month and there is no specific number. https://xxxxx.com/sites/sitecollection/SiteA/SubsiteB(same thing goes with C,D,... ). So this is the hierarchy.

All the sites (Site A, Subsite B, Subsite C, Subsite D.....) have lists (List A, List B, List C, List D,....)respectively that are tagged with a unique Content Type, Lets Call it Content Type X.(I have created this content type, not a system generated one). What i mean is (Content type of List A, B, C and D..... are same, but the data is unique).

I am trying to pull all the list items under List A, List B, List C and List D and ....(that are tagged with this Content Type X) using Rest API.

If its just one list, you can use this "/_api/web/lists/getbytitle('List A')/items?$select=Title,URL,ContentType/Name&$expand=ContentType&$filter=ContentType eq 'Content Type X'".

But the challenging part is, I want to pull all list items from the List A, List B, List C,..... dynamically

Any suggestions will be helpful.


4 Answers 4


The best way to get all items belonging to a content type under a site collection would be to use the Search REST API. Since data will already be indexed, it is the fastest way to get items.

You can set the Search API to use the Content Type and Path attributes which will restrict it fetch items accordingly.

The endpoint would be as below:

/_api/search/query?querytext='ContentTypeId:0x01005FC5182DF0BF554287F15C4D8B798E6* + path:https://sitecollectionurl/*'&selectproperties='Title,Path'

Now, to get the values of columns, add those columns Managed properties in the selectproperties parameter.

You can get the ID of your content type using the following steps:

  • Hello Gautham, Thanks for your response. This looks like it would work. Just a small correction, i am trying to pull all list items that belong to a content type under a specific site and all its sub sites rather than the whole site collection. So, can i simple pass the site URL? Will it also fetch with in the sub sites of this site?
    – AXA240778
    Jan 22, 2018 at 18:19
  • yes, sorry missed the *. Have modified the path to path:https://sitecollectionurl/* so that it will include all items having the path that is inside site collection. So, it will indeed include items from site collection as well as subsite Jan 23, 2018 at 4:49

You need to get all lists from the site firstly, and create a variable for list title, set the variables as results you got.


http://www.c-sharpcorner.com/UploadFile/anavijai/how-to-get-all-the-lists-in-sharepoint-2013-online-using-res/ http://www.c-sharpcorner.com/article/how-to-get-all-list-items-of-a-list-using-rest-api-in-sharepoint-online-and-offi/

Where do you want to put this data? If in an excel file, you can try to run the PowerShell script, here is a demo: https://sharepointmates.com/2017/07/07/get-all-lists-items-in-a-site-collection-using-power-shell-in-sharepoint-online/


I don't think you can use REST to query multiple lists in this manner. I would have a look at using CSOM instead.

Query multiple lists using javascript/CSOM

or maybe this longshot shortcut will help

How do I query the SharePoint content type collection and get content types of an content type group?


Use search API:

    var searchApi = '/_api/search/query?querytext=%27ContentType:"CT Name"'
    var selectedParameter = '&trimduplicates=false&rowlimit=%27500%27&selectproperties=%27LastNameOWSTEXT,FirstNameOWSTEXT,Title%27';
    var searchQuery = _spPageContextInfo.siteAbsoluteUrl +searchApi + ' %27' + selectedParameter
    var query = "";
    var myJsonString = "";
        url: searchQuery,
        type: "GET",
        headers: {
            "Accept": "application/json;odata=verbose"
        async: false,
        success: function (data, textStatus, xhr) 
            var values = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;

        error: function (data) {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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