How to move a page in Confluence with Python API
Asked by Marlene Pirker:

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?**


Answers:
author: Dario B
body: Hello [@Marlene Pirker](/t5/user/viewprofilepage/user-id/4394046) ,

If I understand correctly you are trying to clone a Confluence page via REST API using the [Atlassian Python API](https://github.com/atlassian-api/atlassian-python-api).

Now, if this is correct I can tell you that:

* The [Atlassian Python API](https://github.com/atlassian-api/atlassian-python-api) is neither built nor supported by Atlassian
* The issue is not with the [Confluence Cloud REST API](https://developer.atlassian.com/cloud/confluence/rest/intro/#about) but with the [Atlassian Python API](https://github.com/atlassian-api/atlassian-python-api) itself and there seems to be an open issue for this in their GitHub account: <https://github.com/atlassian-api/atlassian-python-api/issues/782>
* In case of any problem with this 3rd party API, you should create an issue in: [https://github.com/atlassian-api/atlassian-python-api/issues](https://github.com/atlassian-api/atlassian-python-api/issues?)

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](https://github.com/atlassian-api/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:

* <https://developer.atlassian.com/cloud/confluence/rest/api-group-content---children-and-descendants/#api-api-content-id-copy-post>

> ### Copy single page {#toc-hId-1255172589}
>
> 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

comments: author: Marlene Pirker
body: Thank you! I will read the documentation and will reach out if I have further questions.


Tags: api

cloud

confluence-cloud

python