Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,554,351
Community Members
 
Community Events
184
Community Groups

Copy page hierarchy in Confluence Server via REST API

Hi all,

I am trying to copy a page hierarchy from one space to another space via the Confluence REST API. In the Confluence Cloud API there exists

POST /wiki/rest/api/content/{id}/pagehierarchy/copy

(see https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-pagehierarchy-copy-post).

 

On the server version I am getting a 404 error when trying to use this interface (note that authorization is not the problem). Is this functionality only available in the cloud version?

 

PS: In the cloud version it worked fine.

2 answers

Hi,

I have the same need here (copy a page hierarchy to another space)... I've installed REST api browser, but it really seems like this function is not available on server ...

Any ideas, anyone?

Thanks,

Did you ever find it?

I have confluence 6.5.0.

I am looking for a way to copy the page hierarchy using a rest api, not the ui.

Ok, my bad. The api is private. I was looking at the public apis.

Like Rodrigo Silva likes this

I have confluence 7.13.2

@Danilo Yasushi SaitaDid you find a way to copy the page hierarchy using a rest api on the server version ?

0 votes
edwin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Dec 20, 2017

Hi,

For server it'll be 

POST /rest/api/content/{id}/pagehierarchy/copy

This is very misleading. There is no such api in Confluence Server.

Like Ron Elazar likes this

@EdwinI tried to use the syntax you suggest, ie:

POST /rest/api/content/{id}/pagehierarchy/copy

 I get error 404. Using the python version, the syntax translates to:

url = "https://my.domain/confluence/rest/api/content/11111/pagehierarchy/copy"
headers = {"Content-Type": "application/json"}
payload = json.dumps( {  
"copyAttachments": True,  
"copyPermissions": True,  
"copyProperties": True,  
"copyLabels": True,  
"destinationPageId": "2222222",  
"titleOptions": {    
"prefix": "aaa",    
"replace": "",    
"search": ""  }} )
rrr = requests.request(   
   "POST",
   url,
   data=payload,
   headers=headers,   
   auth=("user", "password"),
)
print(rrr.text)

 The user I'm connected to has view page rights on the source space, and successfully created the destination space, using the relevant API. Logged in as that user, the copy operation works when using the UI.

I also tried with   "copyPermissions"False,  "copyProperties"False,  "copyLabels"False,

@Francis Vila Found any way to copy page tree using any Confluence REST API?

Hi, I'm using this command below and this works completely fine

import requests

import json

url = 'https://mydomain.atlassian.net/wiki/rest/api/content/pageId/pagehierarchy/copy'




headers = {

    'Content-Type''application/json',

}

payload = json.dumps({

    "copyAttachments"True,   

    "copyPermissions"True,

    "copyProperties"True,  

    "copyLabels"True,  

    "copyCustomContents"True,

     "destinationPageId""destinationPageId",

    })

response = requests.post(

    urlheaders=headersdata=payloadauth=('myname@domain.com''PAT')

    )

print(response.status_code)
Steve Sadler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 22, 2023

@Francis Vila were you ever successful in using that endpoint to copy a page hierarchy?  If so, could you state the solution?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events