Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Confluence REST API gives Error parsing xhtml

I have a spreadsheet that produces an html file which I cut and paste into a HTML widget in Confluence (this works). I am trying to get this html into Confluence using the REST API. 

I have managed to get the page to update using the API with simple stuff but when it comes to updating this HTML file I get the following

{
  "statusCode": 400,
  "data": {
    "authorized": false,
    "valid": true,
    "errors": []
  },
  "message": "Error parsing xhtml"
}

I have escaped all the " using \". This get rid of some errors, however the one above keeps occurring and I'm not sure how to overcome it. I have tried with a small HTML file really simple like a 2 x2 table with short bits of data in each cell. This seems to work ok. The big file I am trying to update the page with has HTML, Javascript and style sheet stuff embedded.

 

I have also tried URIencode but this updates the page with the HTML as text

 

By the way I'm using Postman atm to test out the idea

 

Regards

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Super late reply here but I just spent a few hours wresting list with sucker.

 

I had a template like so, and I was inserting html into the template with pandas' to_html function (which is great btw)

Template looked something like this:

<p> look this is the name of the page. Cool data follows </p>

###TABLE###

<p> now I have more details and ###DATE### </p>

I would re.sub or replace() the ###TABLE### and ###DATE### with outputs from variables just before sending it into the payload. 

 

Anyway, turns out that if i'm outputting a <table>, confluence will return a 400. 

 

The fix:

<p> look this is the name of the page. Cool data follows </p>
<p>
###TABLE###
</p>
<p> now I have more details and ###DATE### </p>

Check your tags and over-<p> everything. This actual fix was seconds of work once I figured out the problem. 

Hopefully this helps!

This error means u have certain charachters that are not xml friendly formatted, replace per the below:

replace chr(13) with <br/>
replace chr(10) with ,
replace " with \"
replace ' with '\
replace & with &amp;

The problem should be solved.

I tried but it gives me 

{"statusCode":400,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"Error parsing xhtml: Unexpected close tag
</XML>; expected
</P>.\n at [row,col {unknown-source}]: [1,14891]"}

Hi,

Its hard to know what may be causing the issue so what you can try is taking that big file that is giving you errors and keep removing code from it until it finally works. This way you can try to pin point where in that file it is failing. Remove whole sections though (opening and closing tag) so if it work then the page can still be rendered correctly. 

 

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you