在我看到的Jira问题中,有些字段带有有效值的下拉列表。我想使用python访问该下拉列表。查看问题的返回字段时,对象的值为customfield_14651
,该对象是value
和id
的对象。 Jira documentation显示有一个custom_field_option()
方法应该返回字段?我打电话给下面的方法:
self.jira = JIRA('https://jira.companyname.com',basic_auth (login['username'], login['password']) )
print self.jira.custom_field_option('14651')
并收到以下错误:
response text = {"errorMessages":["A custom field option with id '14651' does not exist"],"errors":{}}
答案 0 :(得分:0)
Jira具有.fields()
函数,该函数返回您正在使用的帐户可见的所有字段的列表。
from jira import JIRA
jira = JIRA(basic_auth=('username', 'password'), options = {'server': 'url'})
# Fetch all fields
allfields = jira.fields()
# Make a map from field name -> field id
name_map = {field['name']:field['id'] for field in allfields}
name_map
现在是{"field name":"customfield_xxxx", ... }
答案 1 :(得分:0)
在API中执行此操作的方式似乎是:
from jira import JIRA
jira = JIRA(basic_auth=('username', 'password'), options = {'server': 'url'})
# get an example issue that has the field you're interested in
issue = jira("PRJ-1")
meta = jira.editmeta(issue)
# inspect the meta to get the field you want to look at
allowed_values = [v['value'] for v in meta['fields']['customfield_99999']['allowedValues']]