Dears,
I need help
How can I get all pages from subsite in sharepoint using Restfull API?
thanks in advance for your help...
Using REST API /_api/web/lists/GetByTitle('<listname>')
or using Search API /_api/search/query?querytext='<query text>'
.
For example:
<script type="text/javascript" src="https://code.jquery.com/jquery-1.10.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var siteUrl = "http://sp/sites/team/t1";
getPages(siteUrl);
});
function getPages(siteUrl){
$.ajax({
url: siteUrl + "/_api/web/lists/GetByTitle('Pages')/items?$select=FileRef",
method: "GET",
async: false,
headers: {
"Accept": "application/json; odata=verbose"
},
success: function(data) {
$.each(data.d.results,function(index,val){
console.log(val["FileRef"]);
//do somethings
});
},
error: function (data) {
console.log("Error: "+ data);
}
});
}
</script>
Demo:
To get all pages of a site you can use:
http://<subsite url>/_api/web/lists/getbytitle('Site Pages')/items
If you don't know url of subsite, you can get all subsites:
http://<site url>/_api/web/webs