Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get all descendants pages with last modification date

Gueri
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 7, 2025

Hello,

 

Application is Confluence 9.2.0

I want to collecte all page ids that are descendants of a given page id

    def get_with_pagination(self, endpoint: str, params: dict = None) -> List[dict]:

        """Handle paginated API responses"""

        results = []

        start = 0

        limit = 100

 

        while True:

            paginated_params = params.copy() if params else {}

            paginated_params.update({"start": start, "limit": limit})

 

            data = self.get(endpoint, params=paginated_params)

            results.extend(data.get("results", []))

 

            if len(data.get("results", [])) < limit:

                break

            start += limit

 

        return results

                              


In the main :
                      

cql = f"(ancestor={page_id} OR id={page_id})"

get_with_pagination( "/rest/api/content/search", params={"cql": cql, "type": "page"} )

                                                              

I got a result with 767 pages. Great!

 

Now, I want to collect in the same time the last modification date for each page

So now I run my function with expand=version in order to get version.when

 get_with_pagination( "/rest/api/content/search", params={"cql": cql, "type": "page", "expand": "version"} )          

But the result is only 199 pages, a lot of page are missed !!!

 

For example, if I search all the pages from id = "90356189", among the 767 pages I have page with id 383074259 and 203138626.

For sure, these two pages are actually in the space. If I use my browser to go to url https://my-url/pages/viewpage.action?pageId=page_id, I can see page id 383074259 or 203138626.

When I call the api with ancestor and expand=version, the page id 203138626 is missing !

However if I make a simple call to the api only to retrieve the page id 203138626 with option expand=version there is no problem!

So why i can’t retrieve all the page ids with ancestor and expand=version ?

I really don't undesrstand this issue.

 

Regards

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events