Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence Rest API Create Page 500 error

William
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 16, 2022

Hi, 

I try to add a new page with HTML macro from excel VBA via the Confluence REST API.

I managed to add simple hello world HTML. However it failed with 500 error for more complicated HTML generated using "PublishObjects" function in excel.

Here are some code

test = "<ac:structured-macro ac:name=\""html\"" ac:schema-version=\""1\"" ac:macro-id=\""74c5d460-d9c1-4259-9489-5ca2cea8314c\""><ac:plain-text-body><![CDATA[" & tablestring & "]]></ac:plain-text-body></ac:structured-macro>"

content = "{""type"":""page"",""title"":""new page"",""ancestors"":[{""id"":1111111598}], ""space"":{""key"":""XXXXXXXX""},""body"":{""storage"":{""value"":""" & test & """,""representation"":""storage""}}}"

 

Here are HTML content are generated from excel publish function

Remarks:

- tried to change " to \" as mentioned in other post. but still no luck.

- tried to manually create a page and insert the below into HTML macro, and the table can be displayed properly

<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 15">
<link rel=File-List href="16-03-22%2017-05-56_files/filelist.xml">
<style id="Sheet7_10955_Styles">
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
.xl1510955
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:Calibri, sans-serif;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
.xl6310955
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:white;
font-size:11.0pt;
font-weight:700;
font-style:normal;
text-decoration:none;
font-family:Calibri, sans-serif;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
border:.5pt solid #9BC2E6;
background:#5B9BD5;
mso-pattern:#5B9BD5 none;
white-space:nowrap;}
.xl6410955
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:Calibri, sans-serif;
mso-font-charset:0;
mso-number-format:General;
text-align:general;
vertical-align:bottom;
border:.5pt solid #9BC2E6;
background:#DDEBF7;
mso-pattern:#DDEBF7 none;
white-space:nowrap;}
-->
</style>
</head>

<body>
<!--[if !excel]>&nbsp;&nbsp;<![endif]-->
<!--The following information was generated by Microsoft Excel's Publish as Web
Page wizard.-->
<!--If the same item is republished from Excel, all information between the DIV
tags will be replaced.-->
<!----------------------------->
<!--START OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD -->
<!----------------------------->

<div id="Sheet7_10955" align=left x:publishsource="Excel">

<table border=0 cellpadding=0 cellspacing=0 width=250 style='border-collapse:
collapse;table-layout:fixed;width:188pt'>
<col width=250 style='mso-width-source:userset;mso-width-alt:9142;width:188pt'>
<tr height=20 style='height:15.0pt'>
<td height=20 class=xl6310955 align=left width=250 style='height:15.0pt;
width:188pt;font-size:11.0pt;color:white;font-weight:700;text-decoration:
none;text-underline-style:none;text-line-through:none;font-family:Calibri;
border:.5pt solid #9BC2E6;background:#5B9BD5;mso-pattern:#5B9BD5 none'>Confirmed/Closed
Items:</td>
</tr>
<tr height=21 style='height:15.75pt'>
<td height=21 class=xl6410955 align=left style='height:15.75pt;border-top:
none;font-size:12.0pt;color:black;font-weight:400;text-decoration:none;
text-underline-style:none;text-line-through:none;font-family:Calibri;
border:.5pt solid #9BC2E6;background:#DDEBF7;mso-pattern:#DDEBF7 none'>Confirmed
Items</td>
</tr>
<![if supportMisalignedColumns]>
<tr height=0 style='display:none'>
<td width=250 style='width:188pt'></td>
</tr>
<![endif]>
</table>

</div>


<!----------------------------->
<!--END OF OUTPUT FROM EXCEL PUBLISH AS WEB PAGE WIZARD-->
<!----------------------------->
</body>

</html>

1 answer

0 votes
Andrii Maliuta
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2022

Hi @William ,

Wow, even thinking about using VBA to communicate over REST API scares me :) Is it some must-do to use VBA ? Mayne, you can use some other language that better integrates with HTTP REST API communication?

Thanks

William
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 19, 2022

I guess it is not related to languages or platform, http rest api is universal standard. The issue here is that it failed to handle complex html/css

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events