Forums

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

Method to delete page and children with rest api?

Nils Schieschke April 23, 2021

I want to automate deleting certain pages that don't meet certain criteria using the rest api.

At the moment, I have a recursive function that get the children of a page and deletes them using a rest call:

rest.delete(baseUrl + "/content/" + pageId, user, pw);

Using this call, I have to make an API call for every page, which takes ~250 ms per call.
This is too slow for my liking when I have to delete a couple hundred pages.

Is there a way to delete a page and it's children with ONE API call?

1 answer

1 accepted

0 votes
Answer accepted
Thomas Deiler
Community Champion
April 23, 2021

Dear @Nils Schieschke ,

unfortunatelly the rest api has no bulk delete, but you could speed up the recursive deletion when you fork your process for each leaf you have reached.

Example: Your top parent page has three children. For each of its child you start the recursive function in a news fork/thread. And so on.

Concurrent REST calls should be possible. If there is a limitation (I doubt), start the fork/threads with different system users.

So long

Thomas

Nils Schieschke April 26, 2021

Hey Thomas,

while running the deletion in parallel would of course help, the process will not be run threaded, so that is sadly not a viable option.

Thanks,
Nils

Thomas Deiler
Community Champion
April 27, 2021

Dear @Nils Schieschke ,

I think the interesting aspect is, that you can fire (thread) the rest call without waiting for its return.

This would result in a (more or less) synchronos deletion of a page tree. The limit will be maxThreads (of server.xml).

So long

Thomas

Like Nils Schieschke likes this
Nils Schieschke April 27, 2021

Hey @Thomas Deiler ,

you're right, I didn't even think of that.

Thank you!

Thomas Deiler
Community Champion
May 5, 2021

Dear @Nils Schieschke ,

don't forget to press the "green accept answer" button to indicate other readers the successful answering of your question.

Thanks
Thomas

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events