Is it possible to get all content versions using REST API? Today we have a Confluence page with the below versions:
I would like to know whether I can get the above data using REST API. Currently we are using Confluence 5.9.10.
Thanks.
Well, one way to do it would be to call https://<host>/rest/api/content/<pageID>?expand=version,history.previousVersion and then after getting the previous version number calling https://<host>/rest/api/content/<pageID>?expand=version,history.previousVersion&version=<versionNumber>. However, you would have to do this for every version number.
It's not guaranteed to be in your version of Confluence, but you may have https://<host>/rest/experimental/content/<pageId>/version which can get every single version in one call, similar to the way it is displayed on the versions page.
It's a good idea to install the free REST API Browser to be able to see what REST calls are available on your instance (and makes it easier to test).
Thanks for your reply. The first call works fine here. However, the second one returns the below message:
{ "statusCode": 501 }
Considering your example and a page with 6 versions, this is the URL that I'm calling on my side: https://<HOST>/rest/api/content/104021180?expand=version,history.previousVersion&version=1.
Do you think I'm doing something wrong here?
Hi Lucas,
It's possible that you are getting a 501 because you are trying to call a previous version on version #1 (which wouldn't have a previous version. You would need to read the version number from the first response (5 in your example), and then run it with that version - 1 (so https://<HOST>/rest/api/content/104021180?expand=version,history.previousVersion&version=4), until you get to 2, which would be the last one, as it would display version 1 as the previous version.
Alternatively, there's also a nextVersion parameter, so you could use the URL https://<HOST>/rest/api/content/104021180?expand=version,history.nextVersion&version=1 and count up instead of counting down.
It looks like you're new here. Sign in or register to get started.