How do a I get a list of all attachment versions using the Confluence Rest API?

rlewis8 September 9, 2019

Hi,

I'm trying to figure out how to get a list of all the versions of an attachment using the rest api.  In particular, the version number, date and time of each version.  I've tried variations on the rest api url, but haven't had much luck.  I'm probably making a simple mistake.

Things I've tried:

rest/api/content/<Attachment ID>/history

rest/api/content/<Page ID with attachments>/descendant?expand=attachment

rest/api/content/<Page ID with attachments>/child/attachment?expand=container,operations,children,restrictions,history,version,descendants,space

Thank you,

R

5 answers

0 votes
AzZu February 7, 2023

All attachments is also a representative of the "content" like a page.

So, endpoint GET /wiki/rest/api/content/{id}/version is also available for attachments.

For attachment with id att1769484 you can request

curl --request GET \
--url 'https://your-domain.atlassian.net/wiki/rest/api/content/att1769484/version' \
--user 'email@example.com:<api_token>' \ --header 'Accept: application/json'

 

0 votes
max_patera January 23, 2023

I was able to do it using the solution described here: https://confluence.atlassian.com/confkb/how-to-retrieve-all-previous-versions-of-content-using-the-rest-api-1044789048.html

The URL to use is: /rest/experimental/content/{id}/version/

0 votes
francisco.elrio March 27, 2020

thats not working, also i need to list old versions to download and migrate to other platform. I tried all i saw

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 23, 2019

Hello R,

From reviewing your notes and the endpoints you’ve attempted, you should be able to get what you need from the last endpoint you listed. This endpoint should be able to provide what you’re looking for with the expands:

GET /rest/api/content/{id}/child/attachment

Example of what to use: http://example.com/confluence/rest/api/content/1234/child/attachment?filename=myfile.txt&expand=version

This should give your information in a format which will include version and when (this is the date).

Please let us know if this example is helpful in getting your attachment information.

Regards,
Stephen Sifers

Héctor García June 23, 2022

but if the document has n versions for example 9 versions .. how can I list when each version was last updated.....or created....
I found 
https://xxxxxxxxx.atlassian.net/wiki/rest/api/content/xxxxxxxxxx/child/attachment?expand=history.lastUpdated,history.previousVersion&version=1

 

but just list the previous version of  the current one

0 votes
rlewis8 September 23, 2019

Is this possible?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events