I am trying to copy a page to one space to another INCLUDING the attachments. I works to copy the whole page with this code:
#I want to easily copy a page from one space to another space
page_id = confluence.get_page_id("MARLENETES", "NewMarlene(1)")
print(page_id)
# retrieve the page, including its content.
page_c = confluence.get_page_by_id(page_id, expand='body.storage')
#print(page_c)
# the body HTML
body = page_c['body']['storage']['value']
print(body)
parent_id = confluence.get_page_id("NB", "halli2")
for i in range(1, 2):
print('new test'.format(i))
# use the same above to retrieve the parent page's id.
confluence.create_page('MARLENETES', 'NewMarlene({})'.format(i), body, parent_id, type='page', representation='storage', editor='v2')
time.sleep(1)
But the problem is that any images included in the page are not copied. In stackoverflow I found this answer: https://stackoverflow.com/questions/63061984/how-to-move-confluence-pages-along-with-the-contents-from-one-space-to-another-u
I don't want to accept that it "just doesn't work" with Python. Has anybody solved the problem?
Hello @Marlene Pirker ,
If I understand correctly you are trying to clone a Confluence page via REST API using the Atlassian Python API.
Now, if this is correct I can tell you that:
In other words, you should be able to make this work by writing the code to run the REST API calls in Python without using the Atlassian Python API.
Also, I would like to mention that our developers released a new REST API endpoint to copy a page with all the attachments that I believe it's exactly what you are looking for:
Copy single page
POST /wiki/rest/api/content/{id}/copy
Copies a single page and its associated properties, permissions, attachments, and custom contents....
Please review the documentation for the above endpoint and let me know if you have further questions.
Cheers,
Dario
Thank you! I will read the documentation and will reach out if I have further questions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.