如何通过python获取项目的所有字段(隐藏和可见)?

laz*_*bit 5 python jira jira-rest-api

我是 JIRA api (python) 的初学者。我阅读了所有文档但找不到具体的解决方案。我需要特定于特定项目的所有字段。我在 python 中尝试了以下操作:

    allfields=jira.fields()
Run Code Online (Sandbox Code Playgroud)

但这给出了所有项目的所有领域。我尝试使用curl命令:

    /rest/api/2/issue/createmeta?projectKeys=TEST&expand=projects.issuetypes.fields
Run Code Online (Sandbox Code Playgroud)

但这仅返回可见字段。我去过这个文档链接,但没有得到太多帮助。

sen*_*982 0

这可能会返回您需要的内容。

import requests

url = "https://${HOST}/rest/api/2/issue/createmeta?projectKeys=${project-key}&expand=projects.issuetypes.fields"

payload = ""
headers = {
  'Authorization': 'Basic xxxxxxxxxxxxxxxxxxxxxxxxxx'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

Run Code Online (Sandbox Code Playgroud)

响应示例(删除了一些字段):

{
  "expand": "projects",
  "projects": [
    {
      "expand": "issuetypes",
      "id": "14525",
      "key": "project-key",
      "name": "project name",
      "issuetypes": [
        {
          "id": "154",
          "description": "Created by Jira Software - do not edit or delete. Issue type for a big user story that needs to be broken down.",
          "name": "Epic",
          "subtask": false,
          "expand": "fields",
          "fields": {
            "summary": {
              "required": true,
              "schema": {
                "type": "string",
                "system": "summary"
              },
              "name": "Summary",
              "fieldId": "summary",
              "hasDefaultValue": false,
              "operations": [
                "set"
              ]
            },
            "customfield_13540": {
              "required": false,
              "schema": {
                "type": "option",
                "custom": "com.atlassian.jira.plugin.system.customfieldtypes:select",
                "customId": 13540
              },
              "name": "As a ",
              "fieldId": "customfield_13540",
              "hasDefaultValue": true,
              "operations": [
                "set"
              ],
              "allowedValues": [
                {
                  "value": "Basic User",
                  "id": "16480",
                  "disabled": false
                }
              ],
              "defaultValue": {
                "value": "Customer",
                "id": "16488",
                "disabled": false
              }
            },
            "project": {
              "required": true,
              "schema": {
                "type": "project",
                "system": "project"
              },
              "name": "Project",
              "fieldId": "project",
              "hasDefaultValue": false,
              "operations": [
                "set"
              ]
            }
          }
        }
      ]
    }
  ]
}

Run Code Online (Sandbox Code Playgroud)