Get all list Information in a sharepoint site using REST API

0
229
views

DOWNLOAD CODE:   listinfo

In this article, I had explained how to get  all the list information in a sharepoint site  using SharePoint Representational state transfer(REST).

Open a share point site

Now Open sharepoint Designer to create a HTML file to render the content using CEWP (Content editor web part)

Add a jquery reference into it

Code:

<script src=”http://technologygeeks/sites/devsite/SiteAssets/jquery-3.1.1.min.js”></script>

HTML:

<div id=”list-info”>

</div>

REST Api call:

function getItems() {

$.ajax({

url: _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/ “,

type: “GET”,

headers: {

“accept”: “application/json;odata=verbose”,

},

success: function (data) {

var result  = data.d.results;

var Html  = ”;

 

for(var i=0; i<result.length; i++)

{

var GetTitle= result[i].Title;

var GetDescription= result[i].Description;

 

 

Html  = ‘<h6>’+  GetTitle  +'</h6>’;

$(‘#list-info’).append(Html);

}

 

},

error: function (error) {

alert(JSON.stringify(error));

}

});

}

Full code:

<script src=”http://technologygeeks/sites/devsite/SiteAssets/jquery-3.1.1.min.js”></script>

 

 

<div id=”list-info”>

</div>

 

<script>

$(document).ready(function(){

getItems();

});

 

 

function getItems() {

$.ajax({

url: _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/ “,

type: “GET”,

headers: {

“accept”: “application/json;odata=verbose”,

},

success: function (data) {

var result  = data.d.results;

var Html  = ”;

for(var i=0; i<result.length; i++)

{

var GetTitle= result[i].Title;

var GetDescription= result[i].Description;

 

 

Html  = ‘<h6>’+  GetTitle  +'</h6>’;

$(‘#list-info’).append(Html);

}

},

error: function (error) {

alert(JSON.stringify(error));

}

});

}

</script>

Final result:

 

 

 

Happy share pointing!

Please follow and like us:
0

LEAVE A REPLY

Please enter your comment!
Please enter your name here