How do I create a new space giving admin rights to specific users, using confluence cloud API?

Using confluence cloud API, I need to create a new confluence space giving admin rights to a specific user for that new space.

I tried:

        payload = {
            "key": space_key,
            "name": space_name,
            "description":
                {
                    "plain": {
                        "value": "",
                        "representation": "plain"
                    }
                },
            "permissions":
                [
                    {
                        "operation": {
                            "operation": "administer",
                            "targetType": "space"
                        },
                        "subjects": {
                            "user":
                                [
                                    {
                                        "username": "dom"
                                    }
                                ],
                            "group": []
                        },
                        "anonymousAccess": False,
                        "unlicensedAccess": False
                    }
                ]
        }
        response = self.session.post(self.confluence_server_url + '/rest/api/space',
                                     data=json.dumps(payload), json=True,
                                     headers={'Content-Type': 'application/json'})

        response = response.json()
        print('XXX')
        print(response)

I see the following traces:

api_1       | XXX
api_1       | {'_links': {'self': 'https://elementai.atlassian.net/wiki/rest/api/space/TESTDOMA', 'webui': '/spaces/TESTDOMA', 'context': '/wiki', 'collection': '/rest/api/space', 'base': 'https://elementai.atlassian.net/wiki'}, 'permissions': [], 'id': 40337735, 'key': 'TESTDOMA', 'description': {'plain': {'embeddedContent': [], 'representation': 'plain', 'value': ''}, '_expandable': {'view': ''}}, 'status': 'current', '_expandable': {'metadata': '', 'settings': '/rest/api/space/TESTDOMA/settings', 'icon': '', 'lookAndFeel': '/rest/api/settings/lookandfeel?spaceKey=TESTDOMA', 'theme': '/rest/api/space/TESTDOMA/theme', 'operations': '', 'homepage': '/rest/api/content/40337742'}, 'type': 'global', 'name': 'test-dom-admin13'}

so I assumed the space had been created… but it turned out it wasn’t. ;(
I get a “Oops, you’ve found a dead link” when I try to access the URL where the new space should be…

Any idea what went wrong?
An working example of the above payload would greatly help me.

Thanks!

Hey dom,

I looked into it and it seems to be a bug. I created a ticket you can follow here:
https://jira.atlassian.com/browse/CONFCLOUD-57682

2 Likes