I have a list built using web part. I want count of that web part list.


I have List A. Created list B and added web part into it which points to list A.

I want list item count of list B.

I used '/_api/web/lists/GetByTitle('list B')/items'. But I am getting 0 as count though there are many items.

I don't want to return count of list A. So is there any approach to get count of web part list?


function GetWebPartPageItems(ListName)
url:_spPageContextInfo.webAbsoluteUrl +"/_api/web/lists/GetByTitle('List B')?$select=ItemCount",
    type: "GET",  
    headers: {  
        "accept": "application/json;odata=verbose",  
        "content-Type": "application/json;odata=verbose"  
    success: function(data) {  
    error: function(error) {  

When url is hit in browser,I get resopnse as:

<?xml version="1.0" encoding="utf-8"?><entry 
xml:base="http://sharepoint.brainvire.com/sites/DMS/_api/" xmlns="http://www.w3.org/2005/Atom" 
xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:etag="&quot;40&quot;"><id>http://sharepoint.brainvire.com/sites/DMS/_api/Web/Lists(guid'514f92fb-ccd7-497c-81b9-b74fc074ee37')</id><category term="SP.List" 
scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /><link 
rel="edit" href="Web/Lists(guid'514f92fb-ccd7-497c-81b9-b74fc074ee37')" /><title />
<updated>2019-08-05T10:34:16Z</updated><author><name /></author>
<content type="application/xml"><m:properties><d:ItemCount m:type="Edm.Int32">0</d:ItemCount>

In list,items are present:

enter image description here

  • I am not getting this Created list B and added web part into it which points to list A. Can you please add some details about it? Commented Aug 5, 2019 at 10:18
  • I created list B.Then added web part into it(Edit page-->add web part).Then in categories section,I selected Apps.In Apps category,under part section,I selected list A.
    – user85213
    Commented Aug 5, 2019 at 10:20

1 Answer 1


To get the List Item Count using REST API you need to use:

http://sitename/_api/web/lists/getbytitle('List Name')?$select=ItemCount

Where List Name is display name of your list (Not the list name in URL).

For more clarification check my answer given in below link:

SharePoint rest api not bringing items from List


From Image attached to your question, it seams that the display name of your list is "Pending For Approval". So try using below URL to get the item count:

http://sitename/_api/web/lists/getbytitle('Pending For Approval')?$select=ItemCount
  • It is working if I use same link in browser but implementing same in javascript does not give desired result.
    – user85213
    Commented Aug 5, 2019 at 11:08
  • Can you please add your complete Javascript code to your question? Commented Aug 5, 2019 at 11:09
  • There is an edit in my answer.It is working neither in javascript nor in browser.
    – user85213
    Commented Aug 5, 2019 at 11:21
  • What is the error you are getting while you hit this URL in browser? Commented Aug 5, 2019 at 11:23
  • I am not getting any error.I am getting some xml syntax response.
    – user85213
    Commented Aug 5, 2019 at 11:24

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.