0

Dears,

I need help

How can I get all pages from subsite in sharepoint using Restfull API?

thanks in advance for your help...

2 Answers 2

3

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:

How to get list of all the pages (.aspx ) from a site and all its subsites using REST api or jQuery in SharePoint Onilne?

1
  • It's working fine ... many thanks :) Mar 26, 2019 at 11:29
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.