首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

如何计算JIRA中的评论数量

要计算JIRA中的评论数量,您可以使用JIRA的REST API。以下是一个示例步骤:

  1. 首先,您需要获取JIRA的访问令牌。您可以通过在JIRA界面上进行设置来获取它。
  2. 使用REST API,您可以通过以下URL模式访问JIRA中的评论数量:
代码语言:txt
复制
https://your-jira-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/comment
  1. 在上述URL中,您需要将{issueIdOrKey}替换为您要查询的JIRA问题的ID或键。
  2. 使用HTTP GET请求访问上述URL,并将访问令牌添加到请求头中。例如,您可以使用Python的requests库来执行此操作:
代码语言:python
代码运行次数:0
复制
import requests

url = "https://your-jira-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/comment"
headers = {"Authorization": "Bearer <your-access-token>"}

response = requests.get(url, headers=headers)
  1. 解析响应,以获取评论数量。响应将包含一个JSON对象,其中包含一个名为total的属性,表示评论数量。例如:
代码语言:json
复制
{
  "startAt": 0,
  "maxResults": 50,
  "total": 2,
  "comments": [
    {
      "self": "https://your-jira-domain.atlassian.net/rest/api/3/issue/10010/comment/10000",
      "id": "10000",
      "author": {
        "self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
        "accountId": "123456:abcdef",
        "displayName": "Your Name"
      },
      "body": "This is a comment.",
      "updateAuthor": {
        "self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
        "accountId": "123456:abcdef",
        "displayName": "Your Name"
      },
      "created": "2022-01-01T00:00:00.000+0000",
      "updated": "2022-01-01T00:00:00.000+0000",
      "visibility": {
        "type": "role",
        "value": "Administrators"
      }
    },
    {
      "self": "https://your-jira-domain.atlassian.net/rest/api/3/issue/10010/comment/10001",
      "id": "10001",
      "author": {
        "self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
        "accountId": "123456:abcdef",
        "displayName": "Your Name"
      },
      "body": "This is another comment.",
      "updateAuthor": {
        "self": "https://your-jira-domain.atlassian.net/rest/api/3/user?accountId=123456:abcdef",
        "accountId": "123456:abcdef",
        "displayName": "Your Name"
      },
      "created": "2022-01-02T00:00:00.000+0000",
      "updated": "2022-01-02T00:00:00.000+0000",
      "visibility": {
        "type": "role",
        "value": "Administrators"
      }
    }
  ]
}

在这个例子中,评论数量是2。

请注意,这只是一个示例,您可能需要根据您的具体需求进行调整。

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

领券