It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Get the contents of table in a confluence page using REST API

How can I get the contents of a table in a confluence page using REST API? 

I was able to get the content of the page. But I just want the contents of the table as a list. Any pointers will be appreciated.

5 answers

Yea there is no direct way to get just the table. You have to get all the content and then parse it yourself to get only the table. I am not sure what programming language you are using for this but for python one good library for this is called BeautifulSoup (https://www.crummy.com/software/BeautifulSoup/bs4/doc/).

There are similar libraries like this for other languages so I would look for one in your language and use it to parse the content. 

This relates to the following Confluence Server Page:

Confluence REST API examples

https://developer.atlassian.com/server/confluence/confluence-rest-api-examples/

This page contains examples of using the Confluence Content REST API using curl. The responses are piped into python -mjson.tool (JSON encoder / decoder) to make them easier to read.

0 votes
Steven Behnke Community Leader Aug 11, 2016

Your best bet is to grab the storage format and parse the returned XML for your table.

How did you get the content of the page using REST API? Did it contain table values?

Steven Behnke Community Leader Apr 06, 2018

The REST API (which you can find on google) includes all page content in XML format. Of course it includes a normal html table, yes.

https://<domain>/rest/api/content/12345?expand=body.storage

This format can be used to get the contents of the confluence page. 

Like Nick Spreitzer likes this

Hi,

can any of you provide details about how to scrape table contents from table in confluence page by using rest api & then python script?

you found anything , stucked in same problem.

@Mohan , @Nipun Goel,

For parsing tables I used the following Stack Overflow answer, specifically the response by schmijos.

Use this in tandem with a requests.get for the URL you want from confluence, and make sure to add the following at the end of the URL

?expand=body.view

 

The question was to get contents from a confluence table. This macro is about scraping a webpage URL, get contents and display in Confluence table.

Hows it related?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

2,117 views 4 5
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you