JIRA API - Python Lib - Create_Issue - 选项ID' null'无效

时间:2015-03-11 22:47:39

标签: python client jira

所以我的问题在于JIRA API的Python库。我们正在使用JIRA作为资产管理数据库(是的,我知道它正常用于开发人员,我们也使用它,但这是一个很好的情况)来跟踪服务器配置(内存, CPU,机架上的位置..等等..)

使用此功能我在项目下创建一个问题,并从另一个API中提取字段的信息。

(请注意,我无法提供关于我的工作人员的线索以便编辑代码 - 但是当我添加一行时,所有工作都可以预期)

def create_compute_node_in_jira(self,compute_node_name,user_name,password,info_dic):         help_obj = helper()         jira = JIRA(" https://",basic_auth =(user_name,password))

    #Uses a dic to create the fields / info for the Issue

    issue_dict = {
    'project': {'key': <project>},
    'summary': compute_node_name,
    'issuetype': {'name': 'Server Hardware'},
    'customfield_10500': str(info_dic["Hostname"]), 
    'customfield_11007': {'value': str("2U")}, 
    'customfield_11006': str(info_dic["Aggr0-IP"]),
    'customfield_10510': {'value': str(7)}, 
    'customfield_10501': str(info_dic["Serial-Number"]) 
    'customfield_10502': {'value': str(<server>)},
    'customfield_10503': str(help_obj.data_parser_sm(info_dic["Hostname"])),
    'customfield_10509': {'value': str("<OS>")},  
    'customfield_10504': {'value': str("<mem>")},   
    'customfield_10505': str(help_obj.data_parser_cpu(info_dic["CpuType"])),
    'customfield_10507': {'value': str(info_dic["Cpu-Core"])}, 
    'customfield_10508': {'value': str(<OS Version>)},     
    'customfield_11008': {'value': str("CMH")}
    }
    jira.create_issue(fields=issue_dict)
    return "[*]Created ticket" # Should exit script after this is returned

该行 - &#39; customfield_11008&#39;:{&#39; value&#39;:str(&#34; CMH&#34;)} - 导致该函数返回以下期望:

jira.utils.JIRAError:JiraError HTTP 400     text:选项ID&#39; null&#39;无效     url:https:/// rest / api / 2 / issue

然而,当我省略该行时,它运行时出现问题。我尝试了CMH小写 - 资本..等等。它仍然打破了脚本。我甚至通过网络gui并复制了&#34; CMH&#34;进入另一张票并且平静导致了一个问题。有没有人见过这个/猜测为什么它会破裂?

2 个答案:

答案 0 :(得分:2)

所以经过一段时间玩JIRA后,我发现这是我自己的错误。当您使用API​​向字段发布它不理解的“值”时,似乎会导致此错误。一个例子是我使用了错误的自定义字段,我发布的JIRA字段未设置为采用我正在使用的值。

答案 1 :(得分:0)

当字段的值预期与选项列表匹配时,您将看到此错误,并且您尝试发送不在此列表中的值。