Rest API method to delete page history

Hello XWiki team & community,

I realized that there is a page that has 30k+ versions. :roll_eyes:
Cannot delete the entire page - GUI says ‘page deleted’ but nothing happens in fact.
Trying to delete via rest api throws an error: om.xpn.xwiki.XWikiException: Error number 3232 in 3: Exception while saving deleted document content.

I am only able to delete page versions via GUI, it’s 1700+ pages, so will be clicking “from-to-delete-yes” forever. Is there maybe an SQL query or undocumented Rest method I can use to clean up the history and them delete that page ?

Found magic URL!!!

/bin/deleteversions/mypage2?form_token=[TOKEN]&rev1=2.3484&rev2=1.5535

its possible manually specify wide range of versions to remove
form token could be found from request body send when you normally remove one version via GUI

Normally this url action should be documented at https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Architecture/URL%20Architecture/Standard%20URL%20Format/ but it seems it’s lacking (was created in 2007 prior to this doc).

You don’t need the token, that’s only a CSRF protection. However, you need to pass the confirm query string param.

As in:

/bin/deleteversions/mypage2?confirm&rev1=2.3484&rev2=1.5535

Thanks Vincent,

I managed to delete all versions, then GUI removed the page itself with no issues.
But it would be great to have a possibility to clean up page history via RestAPI.

Cool.

Note this snippet which does something slighty similar: https://snippets.xwiki.org/xwiki/bin/view/Extension/Delete%20Revisions%20From%20Author

I agree that it’s missing. You could create an issue at Loading...

Thanks