无法通过Python在Jira中打开新缺陷(3.6-Jira模块)
这是我的代码:
issue_dict = {
'project': {'key': 'DET'},
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Defect'},
'Severity': {'name' : 'High'},
'defecttype': {'name': 'Performance'},
'affectsversion/s': {'name': 'test'},
'testingstream': {'name': 'CET'},
}
new_issue = jira.create_issue(fields=issue_dict)
我收到有关Jira问题和缺陷屏幕中存在的4个特定字段的错误消息,并且这些选项在jira上有效,
Severity
testingstream
affectsversion/s
defecttype
这是我的错误消息:
JiraError HTTP 400网址:https://jira/rest/api/2/issue文本:无法设置字段“ testingstream”。它不在适当的屏幕上或未知。无法设置字段“严重性”。它不在适当的屏幕上或未知。无法设置字段'affectsversion / s'。它不在适当的屏幕上或未知。无法设置字段“缺陷类型”。它不在适当的屏幕上或未知。响应标头= {'X-AREQUESTID':'769x4311733x3','X-ASESSIONID':'5wjfnu','X-ANODEID':'node1','X-XSS-Protection':'1; mode = block”,“ X-Content-Type-Options”:“ nosniff”,“ X-Frame-Options”:“ SAMEORIGIN”,“ Content-Security-Policy”:“ frame-ancestors'self'”,“ X -ASEN':'SEN-7160564','X-Seraph-LoginReason':'OK','X-AUSERNAME':'user','Cache-Control':'no-cache,no-store,no-transform ','Content-Encoding':'gzip','Vary':'User-Agent','Content-Type':'application / json; charset = UTF-8','Transfer-Encoding':'chunked', 'Date':'Wed,28 Nov 2018 GMT','Connection':'close'}响应文本= {“ errorMessages”:[],“ errors”:{“ testingstream”:“字段'testingstream ',无法设置。它不在适当的屏幕上,或者未知。“,”严重性“:”字段'Severity'不能设置。它不在适当的屏幕上,或者未知。“,”影响版本/ s“: “无法设置字段'affectsversion / s'。它不在适当的屏幕上,或者未知。”,“缺陷类型”:“字段'defecttype'无法设置。它不在适当的屏幕上,或者未知。”} }
有人知道什么地方可能出问题吗?
提前谢谢!
答案 0 :(得分:1)
您的字段不是标准字段。它们是自定义字段。要获取映射,您应该提出请求:
from pprint import pprint
allfields = jira.fields()
name_map = {field['name']:field['id'] for field in allfields}
pprint(name_map)
有了映射后,您可以使用代码创建问题:
new_issue = jira.create_issue(fields={name_map['Severity']: {'value': 'Minor'}, 'project': 'DET', 'issuetype': 'Defect', 'summary': 'New issue from jira-python'})
希望,我帮助了:)