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,467,826
Community Members
 
Community Events
177
Community Groups

Move page to new parent with Confluence Cloud REST API

I'm trying to move pages programatically from one place in the hierarchy to another.  Some claim this can't be done and others claim to have done it with something like this;

 


url = "https://foobar.atlassian.net/wiki/rest/api/content/1147126"

payload = json.dumps(

{"id":1147126,
"type":"page",
"title":"My page 8",
"ancestors":[{"id":1378762}],
"space":{"key":"CD"},
"version":{"number":4}})

headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}

r = requests.request("PUT", url, data=payload, headers=headers, auth=auth)

print(r.ok , r.status_code , r.reason, r.url)

jl = json.loads(r.text)
jl

 

When I run this, I get:

True 200 OK https://foobar.atlassian.net/wiki/rest/api/content/1147126

 

But, in fact, the page is still in the same place when I refresh.

Can anybody help?

 

3 answers

1 accepted

2 votes
Answer accepted

After expending several hours with experiments, I got it to work, sort of. 

The title has to be changed.  

payload = json.dumps(

{"id":1147126,
"type":"page",
"title": "new page 8",
"ancestors":[{"id":1378762}],
"space":{"key":"CD"},
"version":{"number":4}})

Then the version number can be bumped, and the title can be changed back.

payload = json.dumps(

{"id":1147126,
"type":"page",
"title":"My page 8",
"ancestors":[{"id":1378762}],
"space":{"key":"CD"},
"version":{"number":5}})

It's not how I would have designed it.

Thomas Deiler Community Leader Feb 21, 2019

I remember - the version need to be increased manually - I expected this to be done automatically like when you update a page with the browser ...

Like Zak Laughton likes this

The version must be increased TWICE.

In my one week's experience with the REST API, it appears to me that it is ALWAYS necessary to get the page, extract the version, and increase the version in any update.

Like Zak Laughton likes this

Dear rdwyer@metabolon.com ,

at first view the request seems fine. Content update with a new ancestors id. Consider following:

  • check permission or page restrictions
  • get full content first and update the ancestors id only, then PUT again
  • could be a bug (search at https://jira.atlassian.com)

So long

Thomas

Thanks for taking a look.

Like # people like this
Supreet Atlassian Team Jul 03, 2019

Folks, I was able to replicate the issue and created a bug: https://jira.atlassian.com/browse/CONFCLOUD-67046

Meanwhile I would recommend you to try using the workaround of changing page title

There seems to be a (new?) API to move a page in the hierarchy: Move Position 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events