Sandeep Kanabar
Sandeep Kanabar

Reputation: 1302

How to move a child page in confluence using REST API

I have a child page say CP1 listed under Parent page PP1. I need to move the child page CP1 to another Parent page say PP2. How can I achieve that using Confluence REST API?

I couldn't find any documentation related to moving a page in Confluence Docs.

Upvotes: 2

Views: 3158

Answers (1)

Sandeep Kanabar
Sandeep Kanabar

Reputation: 1302

I figured this out eventually. The solution is pretty simple. One merely needs to add this "ancestors":[{"id":<id_of_the_parent_you_want_to_move_under>"}] in the body of the PUT request.

I was also able to find the documentation for the same here which states that "To update a page and change its parent page, supply the ancestors property with the request with the parent as the first ancestor"

Summarizing, assuming you have the title of the page you wish to move, get the content Id and version of the page. Also get the contend Id of the parent you to wish to move the page under. This will be passed to ancestors id field. Then form a PUT request and pass the content Id, title, ancestors and version incremented by 1.

A sample PUT request:

curl -X PUT -H "Authorization: ..." -H "Content-Type: application/json" -d '{"id":1234567,"type":"page", "title":"Your page Title", "ancestors":[{"id":9876543}], "space":{"key":"xxx"},"version":{"number":17}}' "https://abc.def.domain.com/rest/api/content/1234567"

Upvotes: 2

Related Questions