首页 > 解决方案 > 用于区分 Jira Cloud 和 Jira Software(本地)的 API

问题描述

我必须使用 REST API 提取所有 Jira 字段。但是,云版本在响应中有“key”关键字,而本地版本没有。

有什么方法可以确定响应是来自本地还是来自云端。

注意:我必须进行多个 Jira API 调用(创建、提取问题等),因此比较“key”关键字对我来说不是解决方案。

来自 Jira 云的示例响应(获取字段时):

[
    {
        "id": "issuetype",
        "name": "Issue Type",
        "key" : "issuetype",
        "custom": false,
        "orderable": true,
        "navigable": true,
        "searchable": true,
        "clauseNames": [
            "issuetype",
            "type"
        ],
        "schema": {
            "type": "issuetype",
            "system": "issuetype"
        }
    }
]

来自 Jira on-prem 的示例响应(获取字段时):

[
    {
        "id": "issuetype",
        "name": "Issue Type",
        "custom": false,
        "orderable": true,
        "navigable": true,
        "searchable": true,
        "clauseNames": [
            "issuetype",
            "type"
        ],
        "schema": {
            "type": "issuetype",
            "system": "issuetype"
        }
    }
]

是否有任何 API 来区分版本(云或本地)?

标签: javascriptjirajira-rest-api

解决方案


@mdoar 的解决方案(在评论部分)

“我看到rest/api/latest/serverInfo资源有一个名为“部署”的键,其值为 Jira 服务器的“服务器”。这可能会有所帮助“


推荐阅读