Script which result all the space name in a Confluence instance

Rumceisz June 24, 2012

Hi All,

I have a connected Jira and Confluence instance and I have a custom field which contains all the existing space names of the Confluence. This custom field serves the space admins when they request to add users to their own space. In this case they have to select the appropriate space name from this list.

Thw problem is that the space admins use to change the space names very often and it's very cumbersome to update manually the options of this custom field every time.

For first: is there a script which results all the existing space names?

And then I would set this script to a custom field (if I can..)

Thanks in advance for the help!

Rumi

1 answer

1 accepted

2 votes
Answer accepted
David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 25, 2012

Calling http://confluence.example.com/rest/prototype/1/space on a Confluence server would produce some JSON with a list of spaces:

{"expand":"space","space":[{"id":"65537","key":"ds","name":"Demonstration Space","title":"Demonstration Space","link":[{"href":"http://localhost:1990/confluence/rest/prototype/1/space/ds","rel":"self"},{"href":"http://localhost:1990/confluence/display/ds","type":"text/html","rel":"alternate"}],"description":"","lastModifiedDate":{"friendly":"Sep 16, 2008","date":"2008-09-16T13:42:44+0100"},"createdDate":{"friendly":"May 15, 2008","date":"2008-05-15T05:15:14+0100"},"wikiLink":"[ds:]","type":"space"}]}

You could then create the select field from the results

Rumceisz June 25, 2012

Hi David,

I never seen like this? What's that? The link is unavailable.

Rumi

David at David Simpson Apps
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
June 25, 2012

Don't click on the link -- it's only an example! Try this instead: https://confluence.atlassian.com/rest/prototype/1/space It gives XML rather than JSON, but the logic still holds up.

You'll need to login to your Confluence server and replace the hostname with yours.

Admittedly, this doesn't give you the complete answer, but hopefully nudges you in the right direction to get the information you need :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events