How to use Confluence API to get actual data / values from Page Properties Edited

I'd like to use the Confluence API to get the actual data entered for a confluence page tracking statements of work / contracts. I have 1 page per contracted project that uses a global template for users to enter the SOW contract details. Ineed to get the data from each page in this space that I can then pull into a BI analytics tool like Qlik or Tableau to look at projects over time, budgets, deliverables, timelines, etc. and perform calculations, etc. The Page Properties Report macro helps to see a summary of these but I need to also do analysis / report on the data.

I can't figure out what url to use to get at any of this. Here's an example of what we have now

 

And I can connect to the API for the space, I just can't figure out how to get the data now.

https://ourinstancename.atlassian.net/confluence/rest/api/space?spaceKey=OURKEY

 

confluence page properties example.JPG 

 confluence space page tree.jpg

 

3 answers

Is this what you are looking for?

How to retrieve metadata from Page Properties using REST API

Unfortunately I have not found any useful documentation on how to use this API.

EDIT: Space Key is required and headings allows to specify the properties you are looking for.

This seems to be the source code on Bitbucket.

Thanks! I actually just found that one! Bummer about no documentation! 

Did this end up working for you? I keep geting  a 404 error when i try:

https://OURINSTANCE.atlassian.net/confluence/rest/masterdetail/1.0/detailssummary/lines/api/space?spaceKey=OURKEY

We do not use this API since we use our document properties. :-)

But this REST call should work

https://example.com/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage&spaceKey=MYSPACEKEY&headings=key1%2Ckey2%2Ckey3

 Or with cURL

curl 'https://example.com/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage&spaceKey=MYSPACEKEY&headings=key1%2Ckey2%2Ckey3' | jq .

 

Thanks so much. I actually looked at your products but it looks like your tools are only for server and not cloud - is that true?

As far as your example REST call:

I swapped out the example.com for our site and spaceKey for ours, but can’t figure out what the headings are equivalent to?  How do we drill down to the pages and its child pages? I tried w/ our page name like this:

 

 

https://example.com/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage&spaceKey=PDP&headings=Project+ABC+Contract%1  

error:

Unable to locate pages for Page Properties Report. Details: CQL string is \"(type%3Dpage) and macro = details order by lastModified desc\", error message is: \"Could not parse cql : (type%3Dpage) and macro = details order by lastModified desc\"  

 

Then tried a few variations that also failed:

  https://example.com/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage& spaceKey=DP&headings=keyContract+Summary%1  

 

https://example.com/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type%3Dpage& spaceKey=DP.Contract+Summary+-+Open+Contracts&headings= Project+ABC+Contract%1

 

Any insight you have (to this very novice coder!) is greatly appreciated!!!

Thanks!

Thank you for checking out our Web API! Indeed it is only available on Confluence server.

Sorry, it seems that I messed up coping the URL.

The headings are the keys to the page properties.

page-properties.png

This works for me (I snipped off the protocol/server part) using a web browser:

/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type=page&spaceKey=MYSPACEKEY&headings=key1,key2,key3

Here the first characters of the result I get:

{"currentPage":0,"totalPages":17,"renderedHeadings":["key1","key2","key3"],"detailLines":[{"id":70189634,"title":"Example Page with Page Properties","relativeLink":"/display/MYSPACEKEY/Example+Page+with+Page+Properties","details":["value1","value2","value3"],"likesCount":-1,"commentsCount":-1}

I assume that you need to check out the CQL documentation to learn how to navigate through the pages. I would expect that selecting on pages (with something like key1=value1) should be possible, but unfortunately I do not know the syntax (due to the lack of documentation). :(

It seems that the REST API Browser is not available for Cloud. This would be the UI (as an overview over the supported parameters):

 

UI.png

Thanks so much - I'll try this out today. Any thoughts about providing a cloud solution in addition to server? :)

Hi Jessica,

I'm happy if I could give you some links to start with. Hope you figure out how to use the REST API despite the missing docs quickly ... ;)

Thinking about Cloud is what we do, but unfortunately this is still a very, very long way to go. Thank you for your feedback!!

Cheers,

Robert

Hi!

The API answer seems to paginate, but there is no link to the next page... nor parameter to access a page in particular.

Trying to find a workaround, if &pageSize=99 added to the url, detailLines returns empty instead of the 30 detailLines that returns without that parameter.

Any suggestion? 

Thanks in advance,

Luis

I was having this same issue, but I figured it out.  You should see the totalPages in the first part of the results.

{"currentPage":0,"totalPages":17, etc.

To see more pages, add &pageIndex=1 to the request to get the next page. 

If there are 17 pages, &pageIndex=16 would be the last page (0 would be what's included in the first page).

Here's what it would look like to see the second page, using the example given by Robert (above), with the additional pageIndex part:

/confluence/rest/masterdetail/1.0/detailssummary/lines?cql=type=page&spaceKey=MYSPACEKEY&headings=key1,key2,key3&pageIndex=1

Adding &pageSize to the query works for me. Has there been an update ?

It's weird.  Sometimes setting the pageSize to 1000 works, and sometimes, it will only work if I set it up to 62, which is the exact number of records that exist for the cql I put. 

I think it depends on what my headings are.  In particular, it doesn't like the heading "Compliance Plan."  If I change the spelling of it, it gets the data and leaves that field blank.  If I leave that heading in there, it returns no records.  I've tried headings that are longer and shorter, and they work.  I have no idea why it doesn't like that field.

Like I said, weird. 

And, FYI, this API must tie in to the same code the page properties report macro does because there is the same issue of a limit of 500 results regardless of how many pages they display on.  To get more than 500 results, you'd have to do multiple calls/searches.

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 Jul 10, 2018 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 ...

805 views 23 12
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