Getting an confluence page's version through specific API call.

While trying to figure out how to grab the version of a Confluence page via the API I came across another answer on this board that suggested the following kind of page to check for the version.

http://localhost:1990/confluence/rest/api/content/2064387?expand=version

Sure enough, using this format I was able to grab the version of a specific page. However, I noticed something rather odd if I try to get this through other means.

See, I'm trying to get the ID and version of a page via knowing the space and title of the page, via a call like this:

http://localhost:1990/confluence/rest/api/content?title=pageTitle&spaceKey=SPACEKEY

Which returns a json value that has the page ID, like I need, but version comes up... completely blank! Nowhere to be found. Is there a good reason for this or is it a bug? As is, I have to basically call the API twice to get all the information I need for the script I'm writing and that seems kinda silly.

1 answer

2 votes

Hello, you need to add expand=history parameter

http://localhost:1990/confluence/rest/api/content?title=pageTitle&spaceKey=SPACEKEY&expand=history

 

Tried that but version is still blank, as are the previousVersion and nextVersion variables in the history dict.

Ah, however, if I add &expand=version to the line, it does expand version out which includes the "number" variable containing what I need! That's fix enough for me. Thanks for leading me in the right direction!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Tuesday in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

455 views 18 9
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you