Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Using the REST API, I need to get a list of all spaces with the status if archived or not

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?

1 answer

1 accepted

0 votes
Answer accepted
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 17, 2020 • edited

Filter the search results using the status parameter. Its value can be either 'archived' or 'current'

IE /wiki/rest/api/space?status=archived

Refer to this section of the Confluence REST API documentation for more info.

Hi Dave,

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

David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 17, 2020 • edited

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:

"content": {
"title": "Content",
"type": "object",
"properties": {
"status": {
"title": "Content Status",
"type": "object"
},
}

If you provide http://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.

Hi Dave, 

OK, my Server query does work correctly when I use

http://your_confluence_url/confluence/rest/api/space?status=archived

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

"_expandable":{"metadata":"","icon":"","description":"","homepage":"/rest/api/content/15nnnn"}}

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.

David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 18, 2020 • edited

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.

Like Robert Gottesman likes this

>>I'd guess you're using an older version of Confluence Server

The version I'm using is pretty current, vsn 7.3.1

There must be something else I'm missing  :~[

David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 18, 2020

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:

results 
0
id 16777218
key "AO"
name "ActiveObjects Plugin"
type "global"
status "current"
_expandable
settings "/rest/api/space/AO/settings"
metadata ""
operations ""
lookAndFeel "/rest/api/settings/lookandfeel?spaceKey=AO"
identifiers ""
permissions ""
icon ""
description ""
theme "/rest/api/space/AO/theme"
history ""
homepage "/rest/api/content/16744551"
_links
webui "/spaces/AO"
self "https://ecosystem.atlassian.net/wiki/rest/api/space/AO"

Sorry, can't provide any further advice re Confluence Server, as I don't have access to one ATM. 

I have a cloud account and verified your findings .. hence the issue is strictly on the server. Just posted a ticket to Atlassian support ... Once I hear back I will also post that answer here.

Dave, 

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'.

Like Robert likes this
David Bakkers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Sep 21, 2020

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.

Like Robert Gottesman likes this

@Robert Gottesman thanks!

didn't know how to get a description by REST,  I'm got empty description.

But your advice was very helpful!

"to get the description expand 'description.plain'"

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
6.13.8
TAGS
AUG Leaders

Atlassian Community Events