REST API: How to retrieve a list of recently archived pages?

Agnieszka Korotkiewicz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 20, 2023

Is there any way to retrieve a list of recently archived pages?

  • I know it is possible to retrieve archived pages via:

/rest/api/content?status=archived&type=page

but it is not possible to use sorting here.

  • On the other hand, I can use search and sorting

rest/api/content/search?cql=lastModified=2023-04-18%20and%20type=page 

but this does not list the archived pages for me.

I saw that there is a parameter (includeArchivedSpaces), but I don't think I understand how it works (does the whole space have to be archived?). For example:
an archived subpage is not returned by the API despite the parameter being set rest/api/content/search?cql=lastModified=2023-04-20%20and%20type=page&includeArchivedSpaces=true

any other suggestions?

1 answer

0 votes
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.
April 21, 2023

Hello @Agnieszka Korotkiewicz 

With regard the includeArchivedSpaces parameter; Yes, that is for finding content within a space that has been archived. That parameter is not for finding content that has been archived.

It seems that you didn't notice the cqlcontext parameter that can be used with the Search content by CQL endpoint:

 

cqlcontext

string.The space, content, and content status to execute the search against. Specify this as an object with the following properties:
  • spaceKey Key of the space to search against. Optional.
  • contentId ID of the content to search against. Optional. Must be in the space specified by spaceKey.
  • contentStatuses Content statuses to search against. Optional.

 

So, your query would be:

rest/api/content/search?cql=lastModified=2023-04-20%20and%20type=page&cqlcontext=%7B%22contentStatuses%22%3A%5B%22archived%22%5D%7D

The reason for the funky encoding of the cqlcontext parameter is that it expects a JSON object with all the values, so you have to URLEncode it all :(

Refer to this article where it's been discussed before.

Agnieszka Korotkiewicz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 21, 2023

Thank you for your reply. I saw this option, but I tried to add this parameter as a string and it didn't work. However, reading carefully the part of the documentation you sent, I noticed that it should be an object...

Thank you for your help!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events