Creating A New Page Using Confluence Rest API That Has Embedded Tabs Within It

Bhrein Brannick June 9, 2018

Hi there,

 

I have been able to create a confluence page using confluence rest APIs. All good so far.

 

However, I'd like to evolve this and create a page with embedded tabs. Outside of confluence this is trivial to do as you can use html plus css (with javascript if you like although not mandatory). I know their are plugins that create tabbed content but the plugins I have installed don't have a rest api equivalent AFAIK.

 

My questions are as follows:

 

1) Is it possible to add my own custom stylesheet via the rest API so to style the html I send?

 

or

 

2) When sending my html could I set the class attribute to a certain value so that the confluence server would know to interpret this to be tabbed page content on that page?

 

or

 

3) Is there an sample code that is achieving my objective above?

 

Thanks in advance as to any help regarding the above.

1 answer

0 votes
Chii
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2019

When you are using the REST api to create content, you are not sending HTML, but sending confluence storage format. It acts like HTML, but it is not, and you will not be able to directly send any style sheet tags either. 

You need to find and install a plugin containing a macro that displays tabbed content, and send storage format that correspond to that macro in your REST api call. You can find out what the storage format looks like for the tabbed content macro by installing the source editor plugin (https://marketplace.atlassian.com/plugins/com.atlassian.confluence.plugins.editor.confluence-source-editor) and manually creating the page in the editor, then view the source.

If you really want to send HTML directly, and style it with a style tag, you can use the "html" macro (see docs here https://confluence.atlassian.com/doc/html-macro-38273085.html). This is a dangerous macro to enable, as it is basically an open XSS vulnerability - anyone who has edit permission to the page can add any HTML. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events