Move page to different space

Hi,

Is there any way to move a Confluence page from one space to another?

I tried the following two approaches:

  1. Call the Update content REST endpoint and set an ancestor from a different space. Also tried with setting a space key explicitly - as with the Create content endpoint.
    This resulted in an error stating that it is not possible to update the content with an ancestor from a different space.

  2. Call the not publicly documented move endpoint, which is called when the user executes a page move via the Confluence UI. This approach is described here.
    It works, but only with basic auth. I tried this first with JWT authentication and secondly with OAuth, neither did work. JWT resulted in a 403 error “Request not in an authorized API scope”. OAuth resulted in the “Please log in page”.

As neither approach 1. nor approach 2. did work - and also approach 2. is undocumented -, I am looking for a way to move a page from one space to another. Has anyone done this?

One approach coming to my mind would be to let the admin provide user credentials and use the 2. approach. But this also seems more like a workaround and does require additional action by the user.

Cheers
Peter

Hi @pete - looks like there’s already a ticket filed on this one. See https://jira.atlassian.com/browse/CONFCLOUD-67046. Looking in that ticket, there is a workaround. You’ll have to change the title and bump the version number. You can change the title back after it’s moved.

Hi @nmansilla,

Thanks for the reply.

Unfortunately this does not seem to work in my case. Maybe the described approach works only for reordering pages inside one space.

I am sending the body

{
	"type": "page",
	"title": "Name Changed",
	"version": {
		"number": 9
	},
	"ancestors": [
		{ "id":4948039 }
	]
}

to the Update Content endpoint. The page being updated has version 8 and name “Name”, and 4948039 is the ID of a page in a space different from the space where the updated page is. For this request I receive an error:

{
  "statusCode":500,
  "message":"java.lang.IllegalArgumentException: Can't add a parent from another space."
}

When I specify the new space, where the page with ID 4948039 is, explicitly in the request body

{
	"type": "page",
	"title": "Name Changed",
	"version": {
		"number": 9
	},
	"space": {
		"key": "NS"
	},
	"ancestors": [
		{ "id":4948039 }
	]
}

I obtain the following error:

{
  "statusCode":400,
  "data":{"authorized":true,"valid":false,"errors":[{"message":{"key":"You can't change an existing page's space.","args":[]}}],"successful":false},
  "message":"com.atlassian.confluence.api.service.exceptions.BadRequestException: Could not update Content of type : class com.atlassian.confluence.pages.Page with id 867205166"
}

Saying “You can’t change an existing page’s space.”.

Am I doing anything wrong here? Did I misinterpret the workaround? I would appreciate any help regarding this issue.

Cheers
Peter

Well, shame on me for cursory read / cut-and-paste, without testing it out myself. You’re right. So far, I haven’t been able to find a method on my own. I’ll ping the team to see if there’s any other way to do this

Hi @nmansilla,

Is there any chance for you to determine when you will get a reply from the team?

Cheers

I think this was more the issue you were looking for: https://jira.atlassian.com/browse/CONFCLOUD-11350

However, I don’t have access to the associated CRA ticket that shows the current status :frowning:

Thanks @stephendeutsch1, this is exactly what I was looking for.

@nmansilla can you tell us the status of the corresponding CRA ticket?

Doesn’t appear to be any updates on that ticket. I’ll circle back with the team and see if there’s anything to share.