How to get SharePoint list item counts using REST API?
Hello SharePointers
Below is REST API code to get the sharepoint list item counts using REST API.
var ListUrl = _spPageContextInfo.webServerRelativeUrl + “/_api/web/lists/getbytitle(‘yourlistname’)/items”;
getJsonFormat(ListUrl)
.done(function(data)
{
var itemsCount = data.d.results.length;
})
.fail(
function(error){
console.log(JSON.stringify(error));
});
function getJsonFormat(ListUrl)
{
return $.ajax({
url: ListUrl,
type: “GET”,
contentType: “application/json;odata=verbose”,
headers: {
“Accept”: “application/json;odata=verbose”
}
});
}
Happy SharePointing Folks 🙂