with adding comment
The Issue "Closing issues automatically" section mentions:
If a commit message or merge request description contains text matching a defined pattern, all issues referenced in the matched text are closed.
This happens when the commit is pushed to a project’s default branch, or when a commit or merge request is merged into it.
For example, if Closes #4, #6, Related to #5
is included in a Merge Request description, issues #4
and #6
are closed automatically when the MR is merged, but not #5
.
So "comments" are related to commits or MR (Merge Requests), not comment on the issue itself.
The Edit issue API proposes the following call to close an issue:
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/issues/85?state_event=close"
That should be pretty similar to what you have tried, except you need the PAT (Personal Access Token) with the right scope (api).
As the OP found out, the PUT is effective only after posting a comment on said issue: Create new issue note
POST /projects/:id/issues/:issue_iid/notes