API to post inline comment to Merge Request

Hi there,

Using GitLab API it is possible to post a comment to a commit “on a particular line of a particular file” (see here).

On Merge Request in order to add comments it’s required to use the notes resource (see here and here) but the note object does not seem to contain any parameter to comment on a particular line.

From the GitLab UI I’m able to add inline comments to a Merge Request in the Changes tab but when I call the API and look at the corresponding note object createed from my inline comment there is nothing about the inline, it is only a regular note object without any line or line_type parameter…

Anyone knows how to use the API to add inline comments to a Merge Request ?

1 Like

I’m attempting to add gitlab support to Lint Review (github.com/markstory/lint-review) which I use on github currently.
In order to do this I need a method of commenting on the merge request.

Is this possible?

just put “sha”, “line” and “linetype=new” in there, see
https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit

1 Like

Somewhat works, but there is a bizarre quirk: the comment will be referencing specific line in specific file iff it references the line modified by the commit.

I.e. if you changed .gitlab-ci.yml lines 23-25, you can only comment on lines 23, 24 and 25, but not on any others.

The comments created through the UI creates the comments on other lines just fine, and they show up with line_type: null.

Do you know if this is something that can be worked around, or is this a limitation of the API at the moment?

1 Like