I am trying to copy entire page via rest API,
saw an answer in here How to copy a Confluence page via REST API at the right position?, but I do not know what to get from the body.storage and the format on how to pass it in the payload of a post
Community moderators have prevented the ability to post new answers.
I was playing around with Poweshell and the Confluence REST API and created two utility functions, one for copying a page tree and another for deleting a page tree. Perhaps it could be of use to you.
I uploaded the Powershell script to GitHub: https://github.com/ForritAri/ConfluencePageTrees.
Hi all,
with '/rest/api/content' am I able to overwrite an existing page (by page id)?
Or, even better: to create if it does not exist in the target instance->space and overwrite if it exists
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As long as you want to copy it to the same space, I believe this is about the simplest example that could possibly work (using jQuery/Javascript, runnable in your browser console).
var copyPage = function(pageId, newParentId) { jQuery.ajax({ url: contextPath + '/rest/api/content/' + pageId + '?expand=space,body.storage,ancestors', success: function(response) { response.title += " (Copy)"; if (newParentId) { response.ancestors[0].id = newParentId; } jQuery.ajax({ contentType: 'application/json', type: 'POST', url: '/rest/api/content', data: JSON.stringify(response), error: function(response) { console.log(response); } }); } }); }
Just run copyPage("12345") to copy the page to the same parent, and copyPage("12345","67890") to copy the page to be a child of the page with the id of 67890.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.