Skip to content

Can't reply to an individual note via API

We have a discussions API: https://docs.gitlab.com/ee/api/discussions.html#merge-requests

This lists individual notes as well as pre-existing discussions.

In the UI, you can reply to any comment to create a discussion. This API forbids it. See issue-reproduce/comment-reply-api#1

$ curl -s --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" 'https://gitlab.com/api/v4/projects/12154641/issues/1/discussions' | jq
[
  {
    "id": "3a8a5e17ac045939518dc9e0b697248041ef1579",
    "individual_note": true,
    "notes": [
      {
        "id": 166622771,
        "type": null,
        "body": "Top-level comment",
        "attachment": null,
        "author": {
          "id": 443319,
          "name": "Sean McGivern",
          "username": "smcgivern",
          "state": "active",
          "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/443319/avatar.png",
          "web_url": "https://gitlab.com/smcgivern"
        },
        "created_at": "2019-05-03T15:52:47.371Z",
        "updated_at": "2019-05-03T15:52:47.371Z",
        "system": false,
        "noteable_id": 20563994,
        "noteable_type": "Issue",
        "resolvable": false,
        "noteable_iid": 1
      }
    ]
  },
  {
    "id": "4bdb18175bea1928188e664d7aecb2b3902272af",
    "individual_note": false,
    "notes": [
      {
        "id": 166622801,
        "type": "DiscussionNote",
        "body": "Discussion",
        "attachment": null,
        "author": {
          "id": 443319,
          "name": "Sean McGivern",
          "username": "smcgivern",
          "state": "active",
          "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/443319/avatar.png",
          "web_url": "https://gitlab.com/smcgivern"
        },
        "created_at": "2019-05-03T15:52:52.108Z",
        "updated_at": "2019-05-03T15:52:52.108Z",
        "system": false,
        "noteable_id": 20563994,
        "noteable_type": "Issue",
        "resolvable": false,
        "noteable_iid": 1
      }
    ]
  }
]

If I try to reply to the first 'discussion', it fails:

$ curl -s -X POST --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" 'https://gitlab.com/api/v4/projects/12154641/issues/1/discussions/3a8a5e17ac045939518dc9e0b697248041ef1579/notes?body=API+test' | jq
{
  "message": "400 (Bad request) \"Discussion is an individual note.\" not given"
}

The second works (I deleted the note to show the pristine state):

$ curl -s -X POST --header "PRIVATE-TOKEN: $GITLAB_API_TOKEN" 'https://gitlab.com/api/v4/projects/12154641/issues/1/discussions/4bdb18175bea1928188e664d7aecb2b3902272af/notes?body=API+test' | jq
{
  "id": 166623164,
  "type": "DiscussionNote",
  "body": "API test",
  "attachment": null,
  "author": {
    "id": 443319,
    "name": "Sean McGivern",
    "username": "smcgivern",
    "state": "active",
    "avatar_url": "https://assets.gitlab-static.net/uploads/-/system/user/avatar/443319/avatar.png",
    "web_url": "https://gitlab.com/smcgivern"
  },
  "created_at": "2019-05-03T15:54:04.781Z",
  "updated_at": "2019-05-03T15:54:04.781Z",
  "system": false,
  "noteable_id": 20563994,
  "noteable_type": "Issue",
  "resolvable": false,
  "noteable_iid": 1
}