Anyone able to create comments using the content REST API

We’ve tried this payload to the API documented here https://developer.atlassian.com/cloud/confluence/rest/#api-content-post:

{
    body: {
       view: {
          "representation": "string",
          "value": "some comment"
        }
    },
    space: { key: "EXAMPLE" },
    type: "comment",
    ancestors: [{
        id: 1234
    }]
}

but we get a response saying that a container property needs to be sent in the payload too but that doesn’t appear to be documented anywhere…

1 Like

Hi @jbevan,

Seems like a gap in the documentation. I was able to create a comment by adding a container like this:

{
  "type": "comment",
  "space": {
    "key": "test2"
  },
  "body": {
    "storage": {
      "representation": "storage",
      "value": "<p>A new comment</p>"
    }
  },
  "title": "Test comment",
  "container": {
    	"id": 10649626,
        "type" : "global"
  }
}

As for the container object, this might help describe it a bit:

{
  "additionalProperties": false,
  "description": "The new content to add the comment to.",
  "properties": {
    "id": {
      "description": "The `id` of the parent content.",
      "type": "string"
    },
    "type": {
      "description": "The content type.",
      "type": "string"
    }
  },
  "required": ["id", "type"],
  "type": "object"
}

Also, I reported this (Log in with Atlassian account) by clicking the “Give docs feedback” link on the upper right hand corner of the page.

Hope this helps.
Ian

6 Likes

Ah great, thank you!

1 Like

description": “The id of the parent content.”,
What exactly is the ‘parent content’ ? If I got a link like:
https://xxxxxx.atlassian.net/wiki/spaces/~819268686/pages/753401960/The+page+where+Comment+is+posted
~819268686 - is the space id;
753401960 - is the content/page id;
What is the parent content?

Hello @VictorDragnea, the parent content should be the contentId of the content you want to comment to.

2 Likes

Figured it out. Thank you!

1 Like

A post was split to a new topic: Add nested comments via REST