Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Incorrect page format when publishing a confluence page via the Rest API

Luke McKavanagh December 16, 2021

Using curl, I am trying to publish confluence pages in editor value v2, with text aligned in the centre.

The template json structure used to push via curl is as follows. Items marked with XXXXX represent a string that is hidden for integrity reasons.  

{
  "type": "page",
  "title": "XXXXX",
  "status": "current",
  "ancestors":[{"id":XXXXX}],
  "space": {
    "key": "XXXXX"
  },
  "body": {
    "storage": {
      "value": "",
      "representation": "storage"
    }
  },
  "version": {
    "number": "1"
  },
"metadata": {
  "properties":{
    "editor": {
      "value": "v2"
    }
  }
}
}

The results seem to be intermittent. Sometimes the page is published with the text aligned to the left, which I am assuming is a different editing format. Then at other times, the page is uploaded in a different format, with text aligned in the centre.

Any help on this would be greatly appreciated. Thanks! I am also using Jenkins to push this command that is showing the same results.

1 answer

0 votes
David Bakkers
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.
December 19, 2021

Hello @Luke McKavanagh 

If you read the documentation for ADF, it says "Some of these nodes can take marks that define text formatting or embellishment such as centered, bold, italics, and alike"

However, in the list of marks, there is no mention of how to declare centered content. Grrr... incomplete documentation!

So, you have to reverse engineer how to implement centering by creating a page in Confluence that has some centered text, then using the REST API to query that page's content and return the page body in ADF format, which gives a result something like this:

"body": {
"atlas_doc_format": {
"value": "{"type":"doc","content":[{"type":"paragraph","marks":[{"type":"alignment","attrs":{"align":"center"}}],"content":[{"text":"This is centered text","type":"text"}]}],"version":1}"

So, now you know you need to specify a mark of the type alignment with an attribute 'align' with the value 'center' for the content to be centered.

Suggest an answer

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

Atlassian Community Events