Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Create macro via REST API Edited

Hi Viktor,

I have a very similar needs: I need to automatically generate HTML content and PUT it to the Confluence page.

My particular page should contain an "Expand" macro. I tried to copy HTML block containing it from another page and then modify and PUT it to Confluence, but got a view like this:


As you can see - macro doesn't work.

When I looked deeply in HTML code - I saw that each <div> tag containing macro looks like follows:

<div class="content-wrapper">
<div id="expander-2068011896" class="expand-container conf-macro output-block" data-hasbody="true" data-macro-name="expand" data-macro-id="c58eaef6-decc-453b-b27c-4807ca9e9950">
<div id="expander-control-2068011896" class="expand-control"><span class="expand-control-iconicon"> </span><span            class="expand-control-text">Click here to expand...</span></div>



There are some attributes like:

  • id="expander-2068011896"
  • id="expander-control-2068011896"

Maybe the problem is that this ID's generating dynamically by backend once you publishing Confluence page throw web-browser, and works only in particular Confluence page? Just a suggestion...

However, the main question: how can I create HTML code containing Confluence macro, so that the macro will work properly in web-browser, after publishing it by REST API?

@Stephen Sifers, please share your suggestions.

It will be very appreciated!

1 answer

1 accepted

Confluence doesn't use HTML but it's own version of XHTML as its storage format. When you view a page that storage format will be transformed into HTML. As you've already experienced trying to store that view HTML won't work. To create a expand macro you'll want to use the following storage format:

<ac:structured-macro ac:name="expand" ac:schema-version="1">
<ac:rich-text-body> <p>expandable content goes here</p>

That was really unexpected information! Thanks @Sven Schatter _Lively Apps_ for support, it works now!

Suggest an answer

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

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

415 views 23 8
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