如何使用 JIRA Cloud REST 创建关于 jira 问题的内部评论 API

How to create an internal comment on a jira issue using the JIRA Cloud REST API

很难找到关于如何对仅供内部讨论的问题发表评论的明确答案。

JIRA Cloud REST API 文档指定了以下架构,用于在创建或更新事件评论时设置评论属性

https://docs.atlassian.com/jira/REST/cloud/#api/2/issue/{issueIdOrKey}/comment-addComment

"properties": {
    "type": "array",
    "items": {
        "title": "Entity Property",
        "type": "object",
        "properties": {
            "key": {
                "type": "string"
            },
            "value": {}
        },
        "additionalProperties": false
    }
}

要对内部问题发表评论(意味着只有服务台代理可以看到评论),您需要将 sd.public.comment 键设置为 { "internal": true } 这可以通过在创建或更新 API 请求的 body 中传递以下 JSON 来实现。

{
    "properties": {
        "key": "sd.public.comment",
        "value": {
            "internal": true
        }
    }
}

您还需要在请求中设置 Content-Type header。

Content-Type: application/json

以下是使用 Groovy 脚本创建内部评论的示例 - ScriptRunner(一种流行的 JIRA 插件)使用的脚本语言

post("/rest/api/2/issue/${issue.id}/comment")
    .header("Content-Type", "application/json")
    .body([
        body: "This is the text which will appear in the comment",
        properties: [
            [key: "sd.public.comment", value: [ "internal": true ]]
        ]
    ]).asString()

请注意,Object / JSON 映射将根据您使用的脚本语言或 HTTP 请求框架而有所不同。