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.
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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Danilo Yasushi Saita , which version of Confluence are you using? It's now possible to copy page hierarchies, since 6.0 https://confluence.atlassian.com/doc/confluence-6-0-release-notes-844235309.html#Confluence6.0ReleaseNotes-6-0-2
For previous releases, you can use the addon https://marketplace.atlassian.com/apps/22929/copy-page-tree?hosting=server&tab=overview
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.
I have confluence 6.5.0.
I am looking for a way to copy the page hierarchy using a rest api, not the ui.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, my bad. The api is private. I was looking at the public apis.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For server it'll be
POST /rest/api/content/{id}/pagehierarchy/copy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is very misleading. There is no such api in Confluence Server.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Francis Vila Found any way to copy page tree using any Confluence REST API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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(
url, headers=headers, data=payload, auth=('myname@domain.com', 'PAT')
)
print(response.status_code)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Francis Vila were you ever successful in using that endpoint to copy a page hierarchy? If so, could you state the solution?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It seems that the confusion comes due to different versions of confluence:
"YOURCURLPATH\curl.exe" -o "OUTPUT_PATH\output.tmp" -D- -u USER:PASSWORD -X GET -H "Content-Type: application/json; charset=utf-8; accept-charset=utf-8" --url "https://YOUR_SERVER/rest/api/content/SOURCE_PAGE_ID?expand=container,children,body,body.storage,version,children.attachment"
The way with script is more universal: the source and destination could be at different confluence servers, so different user credentials could be used.
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.