Search code examples
c#restgitlabgitlab-api

How to POST a note to an Issue and close this issue


I found an issue and get it's details with:

GET https://localhost/api/v4/projects/2779/issues/2

I can add a new_comment to the issue by:

POST https://localhost/api/v4/projects/2779/issues/2/notes?body=new_comment

how to close this issue at once with adding comment?

I've tried only to close without a comment by:

PUT https://localhost/api/v4/projects/2779/issues/2?state_event=close" and it works but I have to use to request first POST to comment and then PUT to close it.


Solution

  • You can add \n/close to the end of your comment to close the issue with a single API call while adding a comment.

    POST https://localhost/api/v4/projects/2779/issues/2/notes?body=new_comment\n/close

    This works because /close is one of the quick actions.