You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I need to get a list of all spaces and included if archived (or not).
I have successfully retrieved a list of all of my spaces using
url = ... rest/api/space
url = ... rest/spacedirectory/1/search?type=global
Both cases do not return the status value if archived or not. I've tried adding 'status' to expand but that doesn't help.
So, how can I tell if the space is archived or not?
Filter the search results using the status parameter. Its value can be either 'archived' or 'current'
Refer to this section of the Confluence REST API documentation for more info.
Well, you were close. I really wanted to retrieve all Spaces then see each space's status value. However, reading your link, all I have to do is put status in the expand to see the status value.
However, my focus right now is on Confluence Server and the link you sent does not work for Server. The confluence server documentation is not as robust as cloud and reading it does not give me an obvious way to get the 'status' field back with each space.
This is the page I'm looking at for the server REST API - Space
The query for Confluence Server and Cloud look to be identical to me. Both have an identical endpoint "
/rest/api/space" and both support the use of the status= parameter to filter the results.
When you submit a request to
http://your_confluence_url/confluence/rest/api/space?status=archived , as per the Confluence Server documentation, does it or does it not return list of archived spaces?
According to the documentation, that endpoint can return the value of the status of the content of a space, but you have to ask for it specifically using the expand= parameter. On the documentation page, click the button 'schema' to see all the properties that can be returned. A few lines down down you'll see:
"title": "Content Status",
If you provide
tp://your_confluence_url/confluence/rest/api/space?expand then you should be given a list of what properties can be expanded.
So, I'm guessing the expanded request would be
http://your_confluence_url/confluence/rest/api/space?expand=definitions or http://your_confluence_url/confluence/rest/api/space?expand=definitions.content
Sorry, I don't have access to a Confluence Server ATM to test this, so just report your result.
OK, my Server query does work correctly when I use
Where the Cloud and Server separate is on the results. I've tried many expand combinations but I can't get anything from the content structure.
As a side note, for the server query, _expandable returns
I can expand on only those values (like homepage) and get the expected results.
I've tried expanding with: 'defintions', 'defintions.content', 'content', 'content.status', etc. .. all have no effect.
The good news .. I can just search the specific status value and combine as needed. But this is just a haunting curiosity why I can't retrieve back any of values under content.
OK, good to hear you have at least one method of getting the archived vs non-archived spaces.
As for the inability to expand the other properties or the REST API even reporting they're there, I'd guess you're using an older version of Confluence Server that didn't support those methods / properties listed on the linked documentation page.
PS. If this turns out to be the case, remember to mark the answer as accepted.
I just tested against Confluence Cloud and can confirm the status of the space is returned by the endpoint /wiki/rest/api/space
Here's an example of a response:
name "ActiveObjects Plugin"
Sorry, can't provide any further advice re Confluence Server, as I don't have access to one ATM.
I posted an issue to the Atlassian help center and they clarified the situation. You are absolutely correct dealing with the cloud. The cloud doc on Get Spaces is accurate. And in both cases (cloud & server), you can only derive the status value by issuing a query on status.
Atlassian admitted that the schema portrayed in api/space in the Server doc is not correct in that shows the entire schema .. you have to drill down in the middle to find the section that applies to space. It appears the expand options for cloud and server are very similar in that to get information on labels you need to expand 'metadata.labels' and to get the description expand 'description.plain'.
Well done on the persistence and getting clarification from Atlassian.
Yeah, it's a bit of shame when the APIs of Server and Cloud diverge in functionality like this, but it's not that often and sometimes Server allows something nice that Cloud doesn't.