Script which result all the space name in a Confluence instance

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
David Simpson Community Champion Jun 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

Hi David,

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

Rumi

David Simpson Community Champion Jun 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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

390 views 17 9
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you