Data from collapsible section in a Page

How do I get the data from collapsible sections in a confluence page?

Do you mean to get the content of the Expand Macro or what exactly do you mean by “collapsible sections in a confluence page”?

Thanks for the quick reply Sven, so I have tons of expand macro in my page and I need to fetch the details inside them

If you know the macro ids you can use this REST API.

Another way would be to parse the storage format of the page yourself (e.g. using Jsoup). The storage format of expand macros looks like this:

<ac:structured-macro ac:name="expand">
  <ac:parameter ac:name="title">Expand me...</ac:parameter>
    <p>This text is hidden until you expand the section.</p>

It may be useful for you to have a look at this question where they are doing something similar (they are searching for macros with the name “dihk-taskassign-macro” instead of “expand”).

1 Like

I’ll try that. Thanks a lot Sven.

1 Like

hey good folks, I tried this to fetch the details from macro, “{id}/history/{version}/macro/id/{macroId}”. Somehow I’m only getting the macro title only. I’ve even given ? in the URL

Oops - for some reason I assumed you were on Server. To avoid having people like me make this mistake make sure you post in the Confluence Cloud category next time. :wink:

So the link to the REST API reference that I posted is for Server, for Cloud you’ll want to look here.

I tried the API on my Cloud instance it seems to work just fine:


Are you sure you have specified pageVersion, pageId and macroId correctly?

No no it is for server only. Yes I did give proper macro id, also if I do a ?expand=body.view for the whole page, I get a dump of html tables and all that, apparently my macros have tables, how do I exclude it?