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

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

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

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
Community showcase
Published in Confluence Cloud

🏠 Say hello to the new Confluence Home!

Hi Atlassian Community, My name is DJ Chung, and I’m a Product Manager on the Confluence Cloud team. Today, I’m excited to share a new and improved version of Home. The new Home helps you ...

4,409 views 10 51
Read article

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