Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to delete whole page tree with Rest API

Wojciech January 16, 2020

How to delete all 2500 pages having their common ancestor id using rest api?

1 answer

1 accepted

2 votes
Answer accepted
DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2020

@WojciechThis is going to be a multi step process,

  1. Fetch ID of ancestor page
  2. From above API you will get ANCESTOR_ID, now you will need to search for all children on this ancestor, for that you can use CQL based search api
    1. API reference - https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/#content-search
    2. CQL search reference - https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/#ancestor
    3. GET <BASE_URL>/rest/api/content/search?cql=ancestor=ANCESTOR_ID
  3. Above API will give you paginated list content, and from that you can delete elements one by one
    1. API reference - https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/#content-delete
    2. DELETE <BASE_URL>/rest/api/content/{CONTENT_ID}

 

I hope this points you to right direction.

Wojciech January 16, 2020

I was afraid I'd have to do it one by one - that can take a while...

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 16, 2020

@Wojciech  Yup! this is time consuming stuff.

I have also seen this add-on popping up in various discussions/questions related to deleting page tree - https://marketplace.atlassian.com/apps/1215148/delete-child-pages-delete-page-tree?hosting=server&tab=overview

Have a look if this can help you.

Wojciech January 20, 2020

It's ridiculous to pay additionally for functionality that is already there... 

My solution was to ask administrator with highest privileges to click "delete page" and "delete child pages". It took few minutes.

Seems my space privileges weren't enough for this number of subpages.
Also DELETE requests take 2-4 seconds each, so it would take a lot of time to do it that way

DPKJ
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 20, 2020

I happy that your issue is resolved.

I know prices of some add-on which just replicate existing features are not justified at all, it just lack of effective documentation by Atlassian.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events