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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can i create a space from a blueprint in Java

Hey,

this question is very close to this one: create page from blueprint in java

the difference is that my goal is to create a space.

I created a space-blueprint in my plugin and want to create a space based on this blueprint.

 

I found the following classes but can't figure out how i can achieve my goal:

SpaceBlueprintManager  (Is not an OSGI Component - @ComponentImport doesn't work)

SpaceBlueprintService (Seems like it needs the SpaceBlueprintManager, but can't figure out how to get the manager)

 

The ContentBlueprintManager is apparently only for creating pages ..

 

any help is appreciated :)

1 answer

1 accepted

2 votes
Answer accepted

Ok found a REST-Method, no need to use java api:

{host:port}/rest/create-dialog/latest/space-blueprint/create-space

Method: POST

Headers:

Content-Type: application/json

User-Agent: xyz      -> Just use some dummy here e.g. 'xyz' :)

Body:

{

        "name": "NAME",
        "description": "DESCRIPTION",
        "context": { },
        "permissions": "PERMISSIONS",
        "spaceBlueprintId": "ID",
        "spaceKey": "SPACE-KEY"

}

 

You can get the space Blueprint id by using this method:

Method: GET

{host:port}/rest/create-dialog/latest/space-blueprint/list

this will give you a list with all space blueprints and their ids :)

SunRiser Atlassian Team Oct 07, 2019

Thank you @Maximilian 

I tried your suggestion and it works!

The below request creates a space with Knowledge base template

curl -u admin:password -X POST -H 'Content-Type: application/json' -d'{"spaceKey":"KM","name":"KB API Test","spaceBlueprintId":"279af294-8caa-4b6d-88f8-67161c18a060","context":{"name":"KB API Test","spaceKey":"KM","spaceDesc":"REST API Space creation using Knowledge base template ","noPageTitlePrefix":"true","ContentPageTitle":"KB API Test"}}' http://localhost:8090/rest/create-dialog/1.0/space-blueprint/create-space

The key is, we need to specify the spaceBlueprintId as part of JSON payload otherwise it will just create the default blank space. We can also get the spaceBlueprintId for each space template from AO_54C900_SPACE_BLUEPRINT_AO

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

415 views 23 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you