updating chart in confluence through the API
Asked by akumars:

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 rendered![chart.jpg](/t5/image/serverpage/image-id/1004i915398C1F294FA23/image-size/large?v=v2&px=999 "chart.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}


Answers:
author: dasAnderl
body: im trying to do the same thing. make an api call to upload data which is then displayed as a chart. [@akumars](/t5/user/viewprofilepage/user-id/1130399) [@Andrey Khaneev _StiltSoft_](/t5/user/viewprofilepage/user-id/781696) could please provide more information/code how to do this?

comments: author: Andrey Khaneev _StiltSoft_
body: Hello,

Please, take a look at this [REST API](https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/?_ga=2.190931690.1581220226.1515915200-988009106.1488206381#content-update). 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.


author: Andrey Khaneev _StiltSoft_
body: 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.

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