Can I create content in Confluence Cloud using Atlassian Document Format (ADF) rather than storage format?

Should I expect the following cURL command to work?

curl -X POST \
  'https://hello.atlassian.net/wiki/rest/api/content?expand=body.atlas_doc_format' \
  -H 'Accept: application/json' \
  -H 'Authorization: Basic <my token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Test Page",
  "type": "blogpost",
  "space": {
    "key": "EC"
  },
  "status": "draft",
  "body": {
    "atlas_doc_format": {"value":"{\"version\":1,\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Some text in a paragraph\"}]}]}"}
  }
}'

When I run the command it does create a page, but it is an empty page with no content. The response I get contains a body like this:

{
        "atlas_doc_format": {
            "value": "{\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\"}],\"version\":1}",
            "representation": "atlas_doc_format",
            "_expandable": {
                "webresource": "",
                "embeddedContent": "",
                "mediaToken": "",
                "content": "/rest/api/content/521884316?status=draft"
            }
        }
}

Should I expect to be able to create content, in Confluence Cloud, using ADF, via the REST API?

3 Likes

Hello,

Yeah this is a bit confusing since the GET for this works differently.

To get it working, instead of

  "body": {
    "atlas_doc_format": {"value":"{\"version\":1,\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Some text in a paragraph\"}]}]}"}
  }

use

  "body": {
    "editor": {
      "value":"{\"version\":1,\"type\":\"doc\",\"content\":[{\"type\":\"paragraph\",\"content\":[{\"type\":\"text\",\"text\":\"Some text in a paragraph\"}]}]}",
      "representation":"atlas_doc_format"
    }
  }

and it should work.

4 Likes

I created a ticket to make it more consistent: [CONFCLOUD-67547] Trying to create a page for new editor using the REST API isn't consistent - Create and track feature requests for Atlassian products.

1 Like