GitLab API to post inline comment to Merge Request












5















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) but the note object does not seem to contain any parameter to comment on a particular line.



However 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 created 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 GitLab API to add inline comments to a Merge Request ?










share|improve this question



























    5















    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) but the note object does not seem to contain any parameter to comment on a particular line.



    However 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 created 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 GitLab API to add inline comments to a Merge Request ?










    share|improve this question

























      5












      5








      5








      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) but the note object does not seem to contain any parameter to comment on a particular line.



      However 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 created 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 GitLab API to add inline comments to a Merge Request ?










      share|improve this question














      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) but the note object does not seem to contain any parameter to comment on a particular line.



      However 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 created 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 GitLab API to add inline comments to a Merge Request ?







      gitlab






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 17 '17 at 14:55









      stourstour

      5613




      5613
























          2 Answers
          2






          active

          oldest

          votes


















          0














          The notes API is used to only add comments to the Merge Request.



          In order to add inline comments to the source code, you must use this other API endpoint:



          https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit



          But this API sets the comment in the commit list. You will not see the comment anywhere in the "Merge Request" page.






          share|improve this answer































            0














            In order to add inline comments for merge requests, there is Discussions API: https://docs.gitlab.com/ce/api/discussions.html



            Each discussion can contain a position in the code, like that:



                "position": {
            "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
            "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
            "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
            "old_path": "package.json",
            "new_path": "package.json",
            "position_type": "text",
            "old_line": 27,
            "new_line": 27
            },





            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41700244%2fgitlab-api-to-post-inline-comment-to-merge-request%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              The notes API is used to only add comments to the Merge Request.



              In order to add inline comments to the source code, you must use this other API endpoint:



              https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit



              But this API sets the comment in the commit list. You will not see the comment anywhere in the "Merge Request" page.






              share|improve this answer




























                0














                The notes API is used to only add comments to the Merge Request.



                In order to add inline comments to the source code, you must use this other API endpoint:



                https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit



                But this API sets the comment in the commit list. You will not see the comment anywhere in the "Merge Request" page.






                share|improve this answer


























                  0












                  0








                  0







                  The notes API is used to only add comments to the Merge Request.



                  In order to add inline comments to the source code, you must use this other API endpoint:



                  https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit



                  But this API sets the comment in the commit list. You will not see the comment anywhere in the "Merge Request" page.






                  share|improve this answer













                  The notes API is used to only add comments to the Merge Request.



                  In order to add inline comments to the source code, you must use this other API endpoint:



                  https://docs.gitlab.com/ce/api/commits.html#post-comment-to-commit



                  But this API sets the comment in the commit list. You will not see the comment anywhere in the "Merge Request" page.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 9:06









                  veladanveladan

                  1311210




                  1311210

























                      0














                      In order to add inline comments for merge requests, there is Discussions API: https://docs.gitlab.com/ce/api/discussions.html



                      Each discussion can contain a position in the code, like that:



                          "position": {
                      "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
                      "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
                      "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
                      "old_path": "package.json",
                      "new_path": "package.json",
                      "position_type": "text",
                      "old_line": 27,
                      "new_line": 27
                      },





                      share|improve this answer




























                        0














                        In order to add inline comments for merge requests, there is Discussions API: https://docs.gitlab.com/ce/api/discussions.html



                        Each discussion can contain a position in the code, like that:



                            "position": {
                        "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
                        "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
                        "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
                        "old_path": "package.json",
                        "new_path": "package.json",
                        "position_type": "text",
                        "old_line": 27,
                        "new_line": 27
                        },





                        share|improve this answer


























                          0












                          0








                          0







                          In order to add inline comments for merge requests, there is Discussions API: https://docs.gitlab.com/ce/api/discussions.html



                          Each discussion can contain a position in the code, like that:



                              "position": {
                          "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
                          "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
                          "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
                          "old_path": "package.json",
                          "new_path": "package.json",
                          "position_type": "text",
                          "old_line": 27,
                          "new_line": 27
                          },





                          share|improve this answer













                          In order to add inline comments for merge requests, there is Discussions API: https://docs.gitlab.com/ce/api/discussions.html



                          Each discussion can contain a position in the code, like that:



                              "position": {
                          "base_sha": "b5d6e7b1613fca24d250fa8e5bc7bcc3dd6002ef",
                          "start_sha": "7c9c2ead8a320fb7ba0b4e234bd9529a2614e306",
                          "head_sha": "4803c71e6b1833ca72b8b26ef2ecd5adc8a38031",
                          "old_path": "package.json",
                          "new_path": "package.json",
                          "position_type": "text",
                          "old_line": 27,
                          "new_line": 27
                          },






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jan 22 at 10:57









                          Dmitry FrankDmitry Frank

                          5,74564588




                          5,74564588






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f41700244%2fgitlab-api-to-post-inline-comment-to-merge-request%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Full-time equivalent

                              Bicuculline

                              さくらももこ