Forums

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

Publish complex xhtml report to confluence using REST API

Anil Kummari
June 8, 2023

Hi ,

I have a complex  xhtml file with css styling. When i try to publish it to confluence python REST api  i'm seeing 'Error parsing xhtml'. Tried to validate in w3c html validator i see many errors in the document. So, upon converting to html5 , i was able to publish the document but the styling is not applied properly. It would be great if i can publish the html content with perfect rendering in the confluence. Any pointers would be helpful

Sample python code :

 payload = json.dumps(
    {
    "type": "page",
    "title": page_title,
    "ancestors": [{"id":parent_page_id}],
    "space": {"key":space_key},
    "body": {
        "storage":{
            "value": html_content
            "representation": "storage"
        }
    }
} )
    response=requests.post(url,headers=headers,data=payload,auth=auth)

1 answer

0 votes
Aron Gombas _Midori_
Community Champion
June 9, 2023

Confluence is not a full HTML based web server, it uses its own internal format knows as ADF. You can't expect that any CSS thrown to Confluence will just work.

I am quite sure that you need to transform the HTML a bit to match the requirements of Confluence.

Anil Kummari
June 10, 2023

I've converted xhtml to html5 which works perfectly fine on the browser. But CSS styling is not rendered when i view the same html5 on confluence which was created using the REST API. @Aron Gombas _Midori_ 

Anil Kummari
June 11, 2023

is there any workaround so that i can get CSS styling on  confluence page?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events