繁体   English   中英

KeyError:关于通过Python提交JIra Ticket的'project'

[英]KeyError: 'project' on Submitting JIra Ticket through Python

我正在尝试使用Python自动生成Jira票证。 运行我的脚本,我一直在追溯。

我在Ubuntu Linux上使用Python 3.6和3.7运行它(我的IDE指向3.7)。 我在网上广泛搜索了解决方案,但没有发现任何问题。

def ticketBody(sprint, uid, [[other stuff]]):
    return({
        "fields": {
           "project": {"key": "DEV"},
           "summary": "Search Term: " + uid,
           "description": "Some Description",
           "issuetype": {"name": "Bug"},
           "Epic Link": "DEV-1",
           "Sprint": sprint,
           "assignee": "awesomeEngr",
        }
    })

BODY = ticketBody(sprint,uid,[other_params])
authd.create_issue(fields=BODY)

Traceback (most recent call last):
  File "/home/wsherwin/.../python/dataQuality.py", line 68, in <module>
    main()
  File "/home/wsherwin/.../python/dataQuality.py", line 63, in main
    authd.create_issue(fields=BODY)
  File "/home/wsherwin/python-test/lib/python3.7/site-packages/jira/client.py", line 1095, in create_issue
    p = data['fields']['project']
KeyError: 'project'

authd对象取代了jira对象,我无法弄清楚为什么python / Jira找不到我的项目,因为我已经传递了它。

我希望得到这个回归0并得出一个圆满的结论 - 还有一堆门票。

不确定,但我认为你的createBody函数应该只返回字段,而不是带有单个条目“fields”的字典:

def ticketBody(sprint, uid):
    return {
        "project": {"key": "DEV"},
        "summary": "Search Term: " + uid,
        "description": "Some Description",
        "issuetype": {"name": "Bug"},
        "Epic Link": "DEV-1",
        "Sprint": sprint,
        "assignee": "awesomeEngr",
    }

注意:您应该遵循PEP8样式指南并在“ticket_body”中重命名“ticketBody”。

暂无
暂无

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

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