Uploaded image for project: 'Confluence Cloud'
  1. Confluence Cloud
  2. CONFCLOUD-57682

Creating Space with Permissions Not Working (REST API)

    XMLWordPrintable

Details

    Description

      In an attempt to answer https://community.developer.atlassian.com/t/how-do-i-create-a-new-space-giving-admin-rights-to-specific-users-using-confluence-cloud-api/8985, I tried the below, and found a bug.

      1) First I created group called 'group1' that I could try giving permissions to.
      2) I tried using the REST API to create a new space (SP1) and grant 'group1' permissions, made POST request:

      {'key': 'SP1',
          'name': 'Space1',
          'permissions': [{
              'operation': {
                  'operation': 'create',
                  'targetType': 'page'
              },
              'subjects': {
                  'group': {
                      'results': [{
                          'type': 'group',
                          'name': 'group1'
                      }],
                      'size': 1
                  }
              },
              'annonymousAccess': False,
              'unlicensedAccess': False
          }]
      }
      

      3) Received Response indicating success:

      {"id":3080194,"key":"SP1","name":"Space1","description":{"plain":{"value":"","representation":"plain","embeddedContent":[]},"_expandable":{"view":""}},"type":"global","permissions":[{"subjects":{"group":{"results":[{"type":"group","name":"group1","_links":{"self":"https://<instance-name>.jira-dev.com/wiki/rest/experimental/group/group1"}}],"size":1},"_expandable":{"user":""}},"operation":{"operation":"create","targetType":"page"},"anonymousAccess":false,"unlicensedAccess":false}],"status":"current","_expandable":{"settings":"/rest/api/space/SP1/settings","metadata":"","operations":"","lookAndFeel":"/rest/api/settings/lookandfeel?spaceKey=SP1","icon":"","theme":"/rest/api/space/SP1/theme","homepage":"/rest/api/content/3080196"},"_links":{"context":"/wiki","self":"https://<instance-name>.jira-dev.com/wiki/rest/api/space/SP1","collection":"/rest/api/space","webui":"/spaces/SP1","base":"https://<instance-name>.jira-dev.com/wiki"}}
      

      4) Next, I visited the 'successfully created space' from the response in step 3:
      https://<instance-name>.jira-dev.com/wiki/rest/api/space/SP1
      5) Turns out, the 'successfully created space' was not created or at least the key could not be found:

      {"statusCode":404,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"No space found with key : SP1"}
      

      6) Just to confirm that spaces were loading, I visited a previously existing space:
      https://<instance-name>.jira-dev.com/wiki/rest/api/space/TES
      7) Received response that proved retrieving a space works:

      {"id":3014659,"key":"TES","name":"testapi","type":"global","status":"current","_expandable":{"settings":"/rest/api/space/TES/settings","metadata":"","operations":"","lookAndFeel":"/rest/api/settings/lookandfeel?spaceKey=TES","permissions":"","icon":"","description":"","theme":"/rest/api/space/TES/theme","homepage":"/rest/api/content/3014709"},"_links":{"context":"/wiki","self":"https://<instance-name>.jira-dev.com/wiki/rest/api/space/TES","collection":"/rest/api/space","webui":"/spaces/TES","base":"https://<instance-name>.jira-dev.com/wiki"}}
      

      8) Then I tried to create the space again with the same POST request in step 2
      9) I received a response indicating step 2 had created the space:

      {"statusCode":400,"data":{"authorized":true,"valid":false,"errors":[{"message":{"translation":"A space already exists with key SP1","args":[]}}],"successful":false},"message":"Cannot create Space"}
      

      Conclusion: BUG!
      A) Steps 2,3 and 8,9 state a space (SP1) has been created
      B) Steps 4,5 states "No space found with key : SP1"

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jjohn@atlassian.com josef
              Votes:
              4 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: