Python 调用 JIRA Rest Api 搜索不返回创建(日期)或解决字段

Python call to JIRA Rest Api search not returning Created (Date) or Resolution fields

正在测试使用 python 进行休息 api 调用以从我的 jira 实例中拉取 defects/bugs。使用 api_docs 中提供的代码,我整理了这个查询:

payload = json.dumps( {
 
  "jql": "issuetype in (Bug,Defect) AND CreatedDate >= 2021\u002f01\u002f01",
  "maxResults": 1,
  #"fieldsByKeys": false,
  "fields": [
   "summary",
   "assignee",
   "reporter",
   "status",
   "resolution"
   "created",
   "updated"
  ],
  "startAt": 0
} )

调用成功,除了 returns 除了 createdresolution 之外的每个字段。我使用 /rest/api/3/field 来确保该字段拼写正确而且确实如此。还尝试了 capitalizing Created.

{
    "id": "created",
    "name": "Created",
    "custom": false,
    "orderable": false,
    "navigable": true,
    "searchable": true,
    "clauseNames": ["created",
    "createdDate"],
    "schema": {
        "type": "datetime",
        "system": "created"
    }
}

API 输出示例:

{
    "expand": "names,schema",
    "issues": [
        {
            "expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
            "fields": {
                "assignee": null,
                "reporter": example,
                "status": example,
                "summary": "DEFECT: Test 1",
                "updated": "2021-03-07T11:14:31.000-0500"
            },
            "id": "123456",
            "key": "Example-4",
            "self": "example_link"
        }
    ],
    "maxResults": 1,
    "startAt": 0,
    "total": 100
} 

或者,当我将 fields 留空时,我会得到所有字段,包括 createdresolution。但是,我不想这样做,因为我们也有数百个自定义字段。

我发现您的代码示例中有错别字。 resolution 字段后缺少逗号。您的代码应该是:

payload = json.dumps( {
 
  "jql": "issuetype in (Bug,Defect) AND CreatedDate >= 2021\u002f01\u002f01",
  "maxResults": 1,
  "fields": [
   "summary",
   "assignee",
   "reporter",
   "status",
   "resolution", # Note the comma here
   "created",
   "updated"
  ],
  "startAt": 0
} )