The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

2 votes
Answer accepted
DPKJ
Community Champion
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 Champion
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 Champion
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.

TAGS
AUG Leaders

Atlassian Community Events