如何使用JIRA Cloud REST API在jira问题上创建内部评论 [英] How to create an internal comment on a jira issue using the JIRA Cloud REST API

查看:156
本文介绍了如何使用JIRA Cloud REST API在jira问题上创建内部评论的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很难找到明确的答案,以解决如何仅针对内部问题的评论.

It's really hard to find a clear answer about how to create a comment on an issue which is internal only.

推荐答案

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

The JIRA Cloud REST API Documentation specifies the following schema for setting properties on comments when creating or updating a comment on an incident

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 } 可以通过在create或update API请求的正文中传递以下JSON来实现.

To make a comment on an issue internal (meaning only service desk agents can see the comment) you need to set the sd.public.comment key to have the value { "internal": true } Which can be achieved by passing the following JSON in the body of the create or update API request.

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

您还需要在请求上设置Content-Type标头.

You will also need to set the Content-Type header on the request.

Content-Type: application/json

以下是使用Groovy脚本创建内部注释的示例,该脚本是ScriptRunner(流行的JIRA插件)使用的脚本语言.

The following is an example of a creating an internal comment using a Groovy script - the scripting language used by ScriptRunner (a popular JIRA plugin)

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()

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

Note that Object / JSON mapping will differ depending on which scripting language or HTTP Request framework you are using.

这篇关于如何使用JIRA Cloud REST API在jira问题上创建内部评论的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆