Créer un site internet

REST get Lists From Current Web

fredericdietrich By On 08/10/2018

In javascript

function getlists() {
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists",
method: "GET",
headers: {
"Accept": "application/json; odata=verbose"
},
success: function (data) {
var lists = data.d.results;
console.clear();
console.dir(lists);
for (var i = 0 ; i < lists.length ; i++) {
var lst = lists[i];
//console.dir(lst);
$.ajax({
async: false,
headers: { "accept": "application/json; odata=verbose" },
method: "GET",
url: lst.RootFolder.__deferred.uri,
success: function (data) {
// get the rootFolder
var folder = data.d;
console.log("Title : " + lst.Title + "; RootFolder :" + folder.ServerRelativeUrl
+ "; Hidden :" + lst.Hidden + "; ItemCount :" + lst.ItemCount + "; LastItemModifiedDate :" + lst.LastItemModifiedDate
+ "; BaseTemplate :" + lst.BaseTemplate);
}
});
 
}
},
error: function (data) {
console.log(data);
}
});
}
get the code only
 

REST

  • No ratings yet - be the first to rate this.