Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to move a page in Confluence with Python API

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? 

1 answer

1 accepted

0 votes
Answer accepted
Dario B Atlassian Team Jun 09, 2021

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.

Like Dario B likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Miss the Confluence demos at Team 21? Watch them here!

Phew, Atlassian Team 2021 blew by. With dozens of demos and a handful of keynotes, you may have missed some of the awesome Confluence Cloud sessions. Don't' worry, you can watch them all here or on Y...

278 views 2 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you