How do you create a new Space using Confluence REST API?

Hi everyone,

I am building a jira plugin which should create a confluence space.
The example in docs POST request of /rest/api/space is working fine, but it adds a standard content on the homepage body and ignores mine.

I tried this json:

{  
   "key":"T14",
   "name":"Test 14",
   "homepage":{  
      "body":{  
         "storage":{  
            "value":"<p>This is the updated text for the new page</p>",
            "representation":"storage"
         }
      }
   },
   "metadata":{}
}

…but it doesn’t work. It does not add my content into the homepage.

In addition, I tried using the PUT /rest/api/space/{spaceKey} rest to update the homepage after creation of the Space:

{
    "key": "T14",
    "name": "Test 14",
    "description": {
        "plain": {
            "value": "This is an example space",
            "representation": "plain",
            "embeddedContent": []
        }
    },
    "homepage":{ 
      "body":{  
         "storage":{  
            "value":"<p>This is the updated text for the new page</p>",
            "representation":"storage"
         }
      }
   },
    "metadata": {}
}

…and it doesn’t work as well.

What is the correct way of adding a content into the homepage during the space creation?

1 Like

Finally I’ve got it worked.
The answer is here:

1 Like