updating chart in confluence through the API

I am trying to update the wiki page with a  chart macro, but does not seem to be updating properly

Getting 200 OK response. But the page looks like this, no chart renderedchart.jpg

Response back has this 

 

{code}

{"storage":{"value":"<table class=\\"wysiwyg-macro\\" style=\\"background-image: url(/wiki/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NoYXJ0Om9yaWVudGF0aW9uPXZlcnRpY2FsfHN0YWNrZWQ9dHJ1ZXxmb3JnaXZlPWZhbHNlfGRhdGFPcmllbnRhdGlvbj12ZXJ0aWNhbHx0eXBlPWJhcnx5TGFiZWw9Y291bnR8eExhYmVsPW5hbWV9&amp;locale=en_GB&amp;version=2);background-repeat: no-repeat;\\"> <tbody> <tr> <td class=\\"wysiwyg-macro-body\\"> <p class=\\"auto-cursor-target\\"> <br /> </p> <table class=\\"confluenceTable wrapped\\"> <tbody> <tr> <th class=\\"confluenceTh\\">col</th> <th class=\\"confluenceTh\\">test2</th> <th colspan=\\"1\\" class=\\"confluenceTh\\">test3</th> </tr> <tr> <td class=\\"confluenceTd\\">1</td> <td class=\\"confluenceTd\\">400</td> <td colspan=\\"1\\" class=\\"confluenceTd\\">6000</td> </tr> <tr> <td class=\\"confluenceTd\\">2</td> <td class=\\"confluenceTd\\">5000</td> <td colspan=\\"1\\" class=\\"confluenceTd\\">3000</td> </tr> <tr> <td class=\\"confluenceTd\\">3</td> <td class=\\"confluenceTd\\">6</td> <td colspan=\\"1\\" class=\\"confluenceTd\\">7000</td> </tr> </tbody> </table> <p class=\\"auto-cursor-target\\"> <br /> </p> </td> </tr> </tbody> </table>","representation":"storage","embeddedContent":[],"_expandable":{"content":"/rest/api/content/156246922"}}

{code}

2 answers

Hello,

As I see you update the page with the page editor format, but it requires page storage format. You can find page storage format in Page Tools (three dots) -> View Storage Format.

Also I can suggest you to move the source table to another page. It is easier to update page with just a table. And on a page with the Chart macro use Page Include macro that will point on the page with the table you update.

Thanks Andrey, i finally figured that out yesterday. I will try out your suggestion for separating the table. Thank you

0 vote
dasAnderl I'm New Here Jan 18, 2018

im trying to do the same thing. make an api call to upload data which is then displayed as a chart. @akumars @Andrey Khaneev [StiltSoft] could please provide more information/code how to do this?

Hello,

Please, take a look at this REST API. With this API you cant set new content of the page. So you need to have page storage format for this purpose. I suppose, chart macro settings will be the same for all you calls while a table with data can change. Then you can create a page with configured chart macro and a dummy table data, copy page storage format and modify its table each time you update the page.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Published 10 hours ago in Confluence

Think you know shares vs. @mentions in Confluence? Take this collab quiz.

To anyone who doubts that Atlassians are a little too obsessed with collaboration, and tools related thereto, let me describe a recent discussion we had (which took place on our internal Confluence, ...

92 views 2 4
Read article

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