Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Can I programmatically copy a Confluence space?

keithrbennett April 2, 2014

I've been asked to devise a way to programmatically copy a space from a Confluence wiki to a new space, changing its name and some other attributes. How would I copy a space using the XML-RPC interface?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Davin Studer
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.
April 3, 2014

The Confluence Command Line interface has a method for this called copySpace.

https://bobswift.atlassian.net/wiki/display/CSOAP/Documentation#Documentation-copySpace

0 votes
Shane Wignall March 25, 2019

For people who come across this thread...

On Confluence server, if you install Copy Space for Confluence, you can copy a space with the following request info:

POST <confluene base url>/spaces/docopyspace.action?key=<source space key>

Content-Type: "application/x-www-form-urlencoded"

Form data:

  • newName: <newSpaceName>
  • newKey: <newSpaceKey>
  • copyComments: "true" (whether or not to copy comments)
  • copyAttachments: "true" (whether or not to copy attachments)
  • confirm: "Save"

You can see this info in the Network view of your browser if you check the "Preserve log" button before copying the space via the UI.

0 votes
Davin Studer
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.
April 4, 2014

You could build out your own copySpace method using the methods exposed with the SOAP api. I'm sure that is probably what Bob has done with his copySpace method.

https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods#RemoteConfluenceMethods-Spaces

keithrbennett April 4, 2014

Davin, I've started doing that. I can see that this may be a formidable task though...I need to know exactly what to copy and what not to copy...and replicating the hierarchy (i.e. the pages' parentId's) will be an interesting exercise. For pages, I've noticed that I have the following keys:

[:id,
:current,
:content,
:title,
:version,
:modifier,
:url,
:homePage,
:creator,
:contentStatus,
:modified,
:created,
:space,
:parentId,
:permissions]

Of these, I'm thinking I should copy content, title, and permissions; but I may also need current, and homePage...and if there are other keys, can I assume they will not be associated with the space and I should therefore copy them? Any thoughts on any of this?

Davin Studer
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.
April 4, 2014

Sounds like you are onto a good start. I knew it would be a formidable task to create your own ... which is why I suggested using the CLI.

keithrbennett April 6, 2014

Based on what I read, I believe that the CLI is mature, stable, and rich in function. However, I'm pretty sure I need an API, and that having a CLI tool will be too coarse an interface for our purposes. That is, I want/need to treat Confluence things like pages and spaces as objects in a running Ruby (or JRuby) program.

Does anyone know of any API libraries, preferably open source ones, in any language, that I could look at, to see how others have interacted with Confluence? I looked within my Ruby community, and could not find any that had enough functionality for what I need.

0 votes
Jobin Kuruvilla [Adaptavist]
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.
April 2, 2014

You can't do rhis using the existing interface. You might want to expose a new REST resource to do this.

keithrbennett April 2, 2014

Thanks, Jobin.

When you say 'existing interface', you mean the XML-RPC interface?

Also, how do you mean, expose a new REST resource? I'm an experienced developer, but am new to Confluence development and web services development. By writing a plugin? I've tried to avoid REST for now because for now I need to support a 4.2.12 instance, and I'm assume the RESTful interface for that version is very limited or nonexistent.

Jobin Kuruvilla [Adaptavist]
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.
April 2, 2014

It is not in any intefraces - XML/RPC, SOAP or REST. I suggested REST because going forward REST is the supported way. Check out https://developer.atlassian.com/display/CONFDEV/REST+Modulefor more details.

If you prefer XML/RPC, here is the doc: https://developer.atlassian.com/display/CONFDEV/RPC+Module

keithrbennett April 4, 2014

I'm writing a Ruby gem (library) that can be used to access our Confluence wiki (with syntactic sugar such as treating pages, spaces, etc., as objects with built-in accessors and mutators to avoid hash notation or 'get' methods) and need to be independent of command line utilities and server plugins. If the Command Line Interface can do it, doesn't that mean that the services I need are already exposed?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events