Skip to main content

Notifications

Community site session details

Community site session details

Session Id : bttY6hPlfNbOnC3vpHNCrR
Power Automate - Building Flows
Answered

Retreving the item count for all lists in a Sharpoint site

Like (0) ShareShare
ReportReport
Posted on 9 Apr 2024 14:37:58 by 87

A simple request - How can I retrieve the item count of all lists in a specific SharePoint site?

 

I know the following uri will get the item count for a specific list when using the SharePoint's HTTP widget

/_api/web/lists/getbytitle('ListName')/ItemCount

 The must be a way to do this for all lists in the site.  Much like the "Site Contents" function in a view.

 

Also, where are all REST API functions documented for SharePoint?

 

Thanks as  always for your time.

Alex

  • AlexLindberg Profile Picture
    87 on 15 Apr 2024 at 14:24:43
    Re: Retreving the item count for all lists in a Sharpoint site

    Thank you for your solution.  I was trying to avoid loops and do-until constructs.

     

    The HTTP REST APIs for getting information from SharePoint exist, but I can't find a simple API that will provide the same information that the "Site contents" URL gives.  That is all I want.  The URL lined is;

     

    https://myCompany.sharepoint.com/sites/MySharePointSite/MySharepointCollection/_layouts/15/viewlsts.aspx

     

    The URI fragment _layouts/15/viewlists.aspx has the answer..... The answer could be a loop as you suggested.

  • Verified answer
    ManishSolanki Profile Picture
    15,085 Super User 2025 Season 1 on 10 Apr 2024 at 03:59:26
    Re: Retreving the item count for all lists in a Sharpoint site

    Hi @AlexLindberg 

     

    Here is the sample flow that generates csv table for all list and libraries in a site.

     

    1. Add "Get all lists and libraries" action to get all list and library of a site:

    ManishSolanki_0-1712721045876.png

     

    2. Add "Apply to each" action and pass the output value object from previous action.

    ManishSolanki_1-1712721128851.png

     

    Inside apply to each block, add "Send an HTTP request to SharePoint" action that uses rest api to get the count of a list or library:

    ManishSolanki_2-1712721254912.png

    /_api/web/lists/getbytitle('@{items('Apply_to_each')?['DisplayName']}')/ItemCount

    Next, add a compose action to collect the name count in an object array:

    ManishSolanki_3-1712721341496.png

    {
    "Name": @{items('Apply_to_each')?['DisplayName']},
    "ItemCount":@{body('Send_an_HTTP_request_to_SharePoint')?['d']?['ItemCount']}
    }

     

    3. Finally, create a csv table from the output of compose action using "Create CSV table" action:

    ManishSolanki_4-1712721410196.png

     

    Output:

    ManishSolanki_5-1712721516352.png

     

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

     

     

     

     

  • Andrew_J Profile Picture
    1,962 Super User 2025 Season 1 on 09 Apr 2024 at 15:11:26
    Re: Retreving the item count for all lists in a Sharpoint site

    @AlexLindberg 

     

    I cannot answer the question on the ALL LISTS but my refrenace for the Rest API is as follows:

     

    https://www.expiscornovus.com/tag/sharepoint-online/

     

    @Expiscornovusinformation has given me the confidence to use them and I have a flow that is working a treat now.  This flow sends out a task list and then through a sperate flow goes in an updates the dates to the following year.  So now I do not have to touch anything.

     

    Also Audrie Gordon has a usefull video on list production using the HTTP.

     

    https://www.youtube.com/watch?v=a9cwdaXd7ec

     

    Regards,

     

    Andrew

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 73

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 66 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard
Loading started