How to get Atlassian Confluence Space permissions by REST API?

3.7k views Asked by At

I'm using Atlassian Confluence REST API. I need to get Space permissions. I couldn't find any info on it in the documentation.

Does anyone know how to get these permissions?

1

There are 1 answers

1
dvdsmpsn On BEST ANSWER

I can see virtually no documentation about this, however having looked at the Confluence REST API Browser, I've got a working example below. You have to be a Confluence admin, or space admin for the space...

POST: http://localhost:1990/confluence/rpc/json-rpc/confluenceservice-v2/getSpacePermissionSets

BODY: [ "ds" ]

RESPONSE:

[
  {
    "type": "SETSPACEPERMISSIONS",
    "spacePermissions": [
      {
        "type": "SETSPACEPERMISSIONS",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "EXPORTSPACE",
    "spacePermissions": [
      {
        "type": "EXPORTSPACE",
        "userName": null,
        "groupName": null
      },
      {
        "type": "EXPORTSPACE",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "EXPORTSPACE",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "SETPAGEPERMISSIONS",
    "spacePermissions": [
      {
        "type": "SETPAGEPERMISSIONS",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "SETPAGEPERMISSIONS",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "REMOVEMAIL",
    "spacePermissions": [
      {
        "type": "REMOVEMAIL",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "REMOVEMAIL",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "REMOVEMAIL",
        "userName": null,
        "groupName": null
      }
    ]
  },
  {
    "type": "REMOVEBLOG",
    "spacePermissions": [
      {
        "type": "REMOVEBLOG",
        "userName": null,
        "groupName": null
      },
      {
        "type": "REMOVEBLOG",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "REMOVEBLOG",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "EXPORTPAGE",
    "spacePermissions": [
      {
        "type": "EXPORTPAGE",
        "userName": null,
        "groupName": null
      },
      {
        "type": "EXPORTPAGE",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "EXPORTPAGE",
        "userName": null,
        "groupName": "confluence-users"
      }
    ]
  },
  {
    "type": "REMOVEATTACHMENT",
    "spacePermissions": [
      {
        "type": "REMOVEATTACHMENT",
        "userName": null,
        "groupName": null
      },
      {
        "type": "REMOVEATTACHMENT",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "REMOVEATTACHMENT",
        "userName": null,
        "groupName": "confluence-users"
      }
    ]
  },
  {
    "type": "CREATEATTACHMENT",
    "spacePermissions": [
      {
        "type": "CREATEATTACHMENT",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "CREATEATTACHMENT",
        "userName": null,
        "groupName": null
      },
      {
        "type": "CREATEATTACHMENT",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "VIEWSPACE",
    "spacePermissions": [
      {
        "type": "VIEWSPACE",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "VIEWSPACE",
        "userName": null,
        "groupName": null
      },
      {
        "type": "VIEWSPACE",
        "userName": null,
        "groupName": "confluence-users"
      }
    ]
  },
  {
    "type": "EDITBLOG",
    "spacePermissions": [
      {
        "type": "EDITBLOG",
        "userName": null,
        "groupName": null
      },
      {
        "type": "EDITBLOG",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "EDITBLOG",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "REMOVEPAGE",
    "spacePermissions": [
      {
        "type": "REMOVEPAGE",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "REMOVEPAGE",
        "userName": null,
        "groupName": null
      },
      {
        "type": "REMOVEPAGE",
        "userName": null,
        "groupName": "confluence-users"
      }
    ]
  },
  {
    "type": "REMOVECOMMENT",
    "spacePermissions": [
      {
        "type": "REMOVECOMMENT",
        "userName": null,
        "groupName": null
      },
      {
        "type": "REMOVECOMMENT",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "REMOVECOMMENT",
        "userName": null,
        "groupName": "confluence-administrators"
      }
    ]
  },
  {
    "type": "EDITSPACE",
    "spacePermissions": [
      {
        "type": "EDITSPACE",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "EDITSPACE",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "EDITSPACE",
        "userName": null,
        "groupName": null
      }
    ]
  },
  {
    "type": "COMMENT",
    "spacePermissions": [
      {
        "type": "COMMENT",
        "userName": null,
        "groupName": "confluence-users"
      },
      {
        "type": "COMMENT",
        "userName": null,
        "groupName": "confluence-administrators"
      },
      {
        "type": "COMMENT",
        "userName": null,
        "groupName": null
      }
    ]
  }
]

It's using the old JSON-RPC REST APIs which have been deprecated and will eventually be replaced. But when they are replaced, you can refactor, right?