Forum Discussion
Americo Perez
May 09, 2018Iron Contributor
Sharepoint Rest: Get library url
Hi, How do I get the library URL? I tried with ServerRestUrl but I am getting undefined :-/ Best regards Americo
Shantha Kumar
May 11, 2018Brass Contributor
Hi,
If you are using SharePoint Online, you can try the below code for retrieving the Library URL,
$.ajax({
url: hostweburl + "/_api/web/AppTiles?$filter=BaseTemplate eq 101",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (response) {
var libItems = "";
$(response.d.results).each(function(){
libItems +="<li><a href='"+this.Target+"'>"+this.Title+"</a></li>";
});
$('#libitems').html(libItems);
console.log(response);
alert(response.d.results.length);
},
error: function (data) {
failure(data);
}
});
SharePoint Online returns the collection of lists, libraries and subsites under the below rest endpoint,
https://<tenant>.sharepoint.com/_api/web/AppTiles
Regards,
Shantha Kumar T