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%2Chistory.previousVersion and then after getting the previous version number calling https://<host>/rest/api/content/<pageID>?expand=version%2Chistory.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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen,
It's still not working. Please check below the previousVersion node of the content.
I'm getting a 501 when I call https://<HOST>/rest/api/content/104021180?expand=version,history.previousVersion&version=4 and https://<HOST>/rest/api/content/104021180?expand=version,history.nextVersion&version=1.
Just to confirm, the pageID is the ID of the current page, right? I'm not a Confluence expert, but looks like the older versions of a page have differents pageID.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Lucas,
I apologize, even though it is there in the documentation and the REST API browser, the version parameter does not appear to be implemented (that's what the 501 refers to), so that's why it doesn't work, not that the pageID changes between versions (the pageID does stay the same for earlier versions).
It seems then that the only options are this https://<host>/rest/experimental/content/<pageId>/version call or https://kb.zanox.com/rpc/json-rpc/confluenceservice-v2/getPageHistory, but the second one has to be called with a POST request, so it's not possible to do it directly from the URL bar in the browser.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Need to get the all versions with single call via REST API. Currently using Confluence 7.19.28
I can't find proper resource in the API. Do you know if there resource that returns All versions of a page like on the screenshot above?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.