Confluence Rest API V2 - Struggling to create a page with the new editor

Hey Dev Community,
I’m running into a bit of a head-scratcher with the new Confluence API and thought I’d reach out to all of you for some help.

Previously, we could create a page using the editor v2, by sending some metadata with the post request on this path

With API V2 things have changed, and the tricks we used doesn’t work anymore :cry:
It seems impossible to post a page with editor v2 with the page api.
Am I missing something, or is it the API ?

3 Likes

Can you share the request body you have used? When I create a page with /wiki/api/v2/pages and the following request body, it uses the v2 editor by default:

{
  "spaceId": "...",
  "status": "current",
  "title": "API page",
  "parentId": "...",
  "body": {
    "representation": "storage",
    "value": "Created with the v2 API"
  }
}

This is the editor content property of the new page:

{
  "id": "...",
  "key": "editor",
  "value": "v2",
  ...
}
1 Like

Yes sure

{
    "spaceId": "...",
    "status": "current",
    "title": "Interesting page title",
    "parentId": "...",
    "body": {
        "representation": "storage",
        "value": "some html stuff"
    }
}

So basically it’s the same payload except for the body value which is some encoded HTML. Maybe this is it, I’ll look into it.

Thank you for your response, by the way.

It appears that the solution to my scenario involves sending the inner content of the HTML body rather than the body as a whole.

So instead of sending:

{
    "spaceId": "...",
    "status": "current",
    "title": "Interesting page title",
    "parentId": "...",
    "body": {
        "representation": "storage",
        "value": "<body><p>The page content</p></body>"
    }
}

We’ll have to send:

{
    "spaceId": "...",
    "status": "current",
    "title": "Interesting page title",
    "parentId": "...",
    "body": {
        "representation": "storage",
        "value": "<p>The page content</p>"
    }
}
1 Like