Confluence REST API - Copy page hierachy

CEDRIC DEVAUX May 15, 2023

Hi,

 

I use the rest api call to duplicate page hierarchy (parent & child pages) from a origin space to destination space.

 

curl --request POST \

--url 'https://your-domain.atlassian.net/wiki/rest/api/content/{id}/pagehierarchy/copy' \ --user 'email@example.com:<api_token>' \

--header 'Accept: application/json' \ --header 'Content-Type: application/json' \

--data '{

"copyAttachments": true,

"copyPermissions": true,

"copyProperties": true,

"copyLabels": true,

"copyCustomContents": true,

"copyDescendants": true,

"destinationPageId": "<string>",

"titleOptions": {

                        "prefix": "<string>",

                        "replace": "<string>",

                        "search": "<string>"

                          }

}'

I use example from Confluence rest api catalog and in the part titleOptions it has 3 properties:

prefix --> I understand that I that to prefix title to allow to copy parent and child pages

 

Could you explain me what is the purpose of "Search" and "replace"  properties?

 

Thank you

 

Cedric

 

1 answer

1 accepted

0 votes
Answer accepted
David Bakkers
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.
May 15, 2023

Hello @CEDRIC DEVAUX 

Those two properties are for searching and replacing words from the titles of the source pages when copying pages in the same space, since Confluence doesn't allow two pages in the same space to have the same title.

For example, if all the titles of the source pages contained the word "dogs" and you wanted all the titles of all the copied pages to use the word "cats" instead, you'd use:

  "titleOptions": {
    "search": "dogs",
"replace": "cats" }

Combined with the prefix property, it gives you a bit more flexibility in ensuring pages copied into the same space have unique titles.

CEDRIC DEVAUX May 16, 2023

Hello David,

Thank you, it's very clear 

Like David Bakkers likes this
Stefan Walther July 10, 2023

Hello @David Bakkers , is there any trick to have more than one parameter being replaced?

Thanks a lot, Regards, Stefan

David Bakkers
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.
July 10, 2023

Hello @Stefan Walther 

Nope.

That endpoint only supports searching for one string in the titles of the source pages and replacing it with one string in titles of the copied pages.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events