我有一个名为“状态”与10100的ID的自定义字段是一个选择列表以“一个”可选值“Two” “三个”和“四个”。默认值是“One”。更新选择列表自定义字段 - 吉拉的Python
我在写一个JIRA python脚本来有条件地更新这个字段的值。如果现有值为“一个”,则应改为“两个”。
这是我的代码。
from jira.client import JIRA
jira_options={'server': 'http://localhost:8080'}
jira=JIRA(options=jira_options,basic_auth=('usrname','pwd'))
for issue in jira.search_issues(' cf[10100] = "One" '):
issue.update(fields={'customfield_10100': 'Two'})
它给我以下错误。
Traceback (most recent call last):
File "test.py", line 11, in <module>
issue.update(fields={'customfield_10100': 'Two'})
File "C:\Python27\lib\site-packages\jira\resources.py", line 193, in update
super(Issue, self).update(**data)
File "C:\Python27\lib\site-packages\jira\resources.py", line 72, in update
raise_on_error(r)
File "C:\Python27\lib\site-packages\jira\exceptions.py", line 29, in raise_on_
error
error = errorMessages[0]
IndexError: list index out of range
请问您可能会出现什么问题? 我曾经使用相同的语法编辑类型文本字段的自定义字段,它工作正常。
是价值应该是一个数组出现如下错误? – mdoar 2013-03-26 16:28:17
对不起,我没有得到查询@mdoar你的意思是选择列表中的选项的值? 定义自定义字段时,我只将它作为字符串。 – ramz 2013-03-26 19:21:06
当试图解决这个问题时,我还观察到,即使存在ID为10100的自定义字段(选择列表),请求“http:// localhost:8080/rest/api/2/customFieldOption/10100”结束了给我一个错误。 '{“errorMessages”:[“ID为'10100'的自定义字段选项不存在”],“errors”:{}}' 奇怪。 – ramz 2013-03-27 11:12:00