如何 POST 注释一个问题并关闭这个问题
How to POST a note to an Issue and close this issue
我发现了一个问题并通过以下方式获取了它的详细信息:
获取https://localhost/api/v4/projects/2779/issues/2
我可以通过以下方式向问题添加 new_comment:
POST https://localhost/api/v4/projects/2779/issues/2/notes?body=new_comment
如何通过添加评论立即关闭此问题?
我试过只关闭而不评论:
放置https://localhost/api/v4/projects/2779/issues/2?state_event=close"
它有效,但我必须先使用请求 POST 进行评论,然后使用 PUT 关闭它。
with adding comment
Issue "Closing issues automatically" section提到:
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
.
因此“评论”与提交或 MR(合并请求)相关,而不是对问题本身发表评论。
Edit issue API 提出以下呼吁来关闭问题:
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/issues/85?state_event=close"
这应该与您尝试过的非常相似,只是您需要带有 right scope (api).
的 PAT(个人访问令牌)
正如 OP 发现的那样,PUT 只有在对上述问题发表评论后才有效:Create new issue note
POST /projects/:id/issues/:issue_iid/notes
您可以在评论末尾添加 \n/close
以在添加评论时通过单个 API 调用关闭问题。
POST https://localhost/api/v4/projects/2779/issues/2/notes?body=new_comment\n/close
之所以有效,是因为 /close
是 quick actions 之一。
我发现了一个问题并通过以下方式获取了它的详细信息:
获取https://localhost/api/v4/projects/2779/issues/2
我可以通过以下方式向问题添加 new_comment:
POST https://localhost/api/v4/projects/2779/issues/2/notes?body=new_comment
如何通过添加评论立即关闭此问题?
我试过只关闭而不评论:
放置https://localhost/api/v4/projects/2779/issues/2?state_event=close"
它有效,但我必须先使用请求 POST 进行评论,然后使用 PUT 关闭它。
with adding comment
Issue "Closing issues automatically" section提到:
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
.
因此“评论”与提交或 MR(合并请求)相关,而不是对问题本身发表评论。
Edit issue API 提出以下呼吁来关闭问题:
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/4/issues/85?state_event=close"
这应该与您尝试过的非常相似,只是您需要带有 right scope (api).
的 PAT(个人访问令牌)正如 OP 发现的那样,PUT 只有在对上述问题发表评论后才有效:Create new issue note
POST /projects/:id/issues/:issue_iid/notes
您可以在评论末尾添加 \n/close
以在添加评论时通过单个 API 调用关闭问题。
POST https://localhost/api/v4/projects/2779/issues/2/notes?body=new_comment\n/close
之所以有效,是因为 /close
是 quick actions 之一。