繁体   English   中英

Jira python设置自定义字段

[英]Jira python set custom field

我在JIRA中尝试在自定义字段上设置值时出现问题,它会返回此错误:

File "c:\python27\lib\site-packages\jira\resilientsession.py", line 45, in raise_on_error
r.status_code, error, r.url, request=request, response=r, **kwargs)
JIRAError: JiraError HTTP 400
    text: Operation value must be a string
    url: http://iasp091x.ia.ro.conti.de:8080/rest/api/2/issue/31424
    response headers = {'X-AUSERNAME': 'continental', 'X-ASEN': 'SEN-5132028', 'X-Content-Type-Options': 'nosniff', 'Content-Encoding': 'gzip', 'Transfer-Encoding': 'chunked', 'X-Seraph-LoginReason': 'OK', 'Vary': 'User-Agent', 'X-AREQUESTID': '850x418015x3', 'X-ASESSIONID': 'gv7hra', 'Connection': 'close', 'Cache-Control': 'no-cache, no-store, no-transform', 'Date': 'Mon, 01 Feb 2016 12:10:49 GMT', 'Server': 'Apache-Coyote/1.1', 'Content-Type': 'application/json;charset=UTF-8'}
    response text = {"errorMessages":[],"errors":{"customfield_11301":"Operation value must be a string"}}

我正在使用的代码是这样的:

new_issue = jira.create_issue(project='PT', summary=issue_summary,
        description=issue_description, issuetype={'name': 'Work'})

new_issue.update(fields={'customfield_11301': [{'value':'test'}]})

自定义字段11301是html中的输入标记:

<input class="textfield text long-field" id="customfield_11301" name="customfield_11301" maxlength="254" value="" type="text">

任何想法如何使这个东西工作?

我找到了解决方案:

def str_to_utf(value):
    if isinstance(value, str):
        return value.decode('latin1')
    return value 



new_issue.update(fields={u'customfield_11301': str_to_utf(user)}) 

这对我来说听起来像个错误,在jira-python库中引发一个bug,有一个可以重现它的例子,我会尽快修复它。

库应该关注编码和解码,而不是你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM