How to use Confluence REST API to post HTML content? Edited

I have done a lot of reading both here and in Stackoverflow. I still cannot make this work, and I am wondering if it is possible. I am using this example:

For some reason I can't reply on that page, so I am writing a new question here.

If I use the field:

'body': {
'representation': 'storage',
'value': str(content)

where the content is:


This posts the string in content, i.e., it doesn't get formatted as a table - actually it adds a space between the tag elements.

Am I missing something, such as the 'html/body' elements in the string that I send in the storage/data field? I also tried adding these, and still it posts the actual string.



PS: I also tried this simple html string: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <h1>My First Heading</h1> <p>My first paragraph.</p> </body> </html>

and that also posts the string itself. So my problem is not about the table, but in figuring out what am I doing wrong in posting HTML so that Confluence will interpret it.


1 answer

Hi , I'm Thomas (beginner)

I work on the same challenge. Dont get the "REST API" example running. Is there a step by step tutorial.

Another interface might be "html-migration" - macro. I activated it but I can not see it in the macro-browser. Same request: is there a step by step tutorial.

I got it to work. In my code, where I show 'value': str(content)
I was making the mistake where I had encoded the content, as you would to for an http encoding. In this case, once I put in the actual string (beginning with<table> ), it worked. 

Suggest an answer

Log in or Join to answer
Community showcase
Louis De Jaeger
Posted Thursday in Off-topic

Friday fun: your best joke

Hi all Lets make this Friday fun really fun and post one (or more) of your best jokes! The joke can be about an Atlassian product, or just a really fun joke you want to share! I’m not the best j...

189 views 12 3
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot