How to create a page with a table using REST API?

I currently have the task of importing a large body of text with many notes and ids and descriptions and would like to represent it in a more readable format of by placing all of these into a series of tables.

Reading the text, extracting information, making connection between data in the text was straightforward enough, as was converting this information into an HTML table.

The problem lies with the actual creation of a page with this table in it, as I cannot send a POST request to create a new page with the raw HTML table as content

$data = array("type" => "page", "title" => "testings".time(), "space" => array("key" => "$uploadSpace"), "body" => array("storage" => array("value" => "$htmlTable", "representation" => "storage")));

because the html wouldnt be properly 'escaped' in PHP I would do this with htmlspecialchars() but sending this up simply shoots up my text with the tags in view and no actual table.

One solution I have found for this would be to contain the entire table in a html macro. This allows viewing of the table, but makes it difficult to edit in the WYSIWYG editor for the people using the wiki, which would make this entire exercise fruitless and I wouldnt like to rely on the macros as much.

$data = array("type" => "page", "title" => "testings".time(), "space" => array("key" => "$uploadSpace"), "body" => array("storage" => array("value" => "<ac:structured-macro ac:name=\"html\"><ac:plain-text-body><![CDATA[$htmlTable]]></ac:plain-text-body></ac:structured-macro>", "representation" => "storage")));

Would appreciate any help thank you.

 

1 answer

You might find it easier to use the Confluence Command Line Interface (CLI). It is much easier to automate creating pages using wiki markup or use csv tables.

You are not answering the question. You are selling another product... Thanks for no response on API usage...

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
Kesha Thillainayagam
Posted Apr 13, 2018 in Confluence

We want to hear how your non-technical teams are using Confluence!

Hi Community! Kesha (kay-sha) from the Confluence marketing team here! Can you share stories with us on how your non-technical (think Marketing, Sales, HR, legal, etc.) teams are using Confluen...

1,989 views 25 10
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