无法使用python创建jira Bug



我使用下面的代码在jira中创建票。我只能创建TASK。当我创建BugStory时,我得到以下错误。

issue_dict = {
'project': {'key': 'TEST'},
'summary': 'New issue from jira-python',
'description': 'Look into this one',
'issuetype': {'name': 'Bug'}
}
new_issue = jira.create_issue(issue_dict)
print(new_issue)

错误:

jira.exceptions.JIRAError: JiraError HTTP 400 url: https://soubhagyapradhan.atlassian.net/rest/api/2/issue

response headers = {'Date': 'Sun, 20 Nov 2022 04:23:17 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge',
'Timing-Allow-Origin': '*', 'X-Arequestid': '023a3f63bfd3ed36e1b1f23637fa115d', 'X-Aaccountid': '5c2cfc199760f569b62799f9', 'Cache-Control':
'no-cache, no-store, no-transform', 'Expect-Ct': 'report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/atlassian-proxy", 
max-age=86400', 'Strict-Transport-Security': 'max-age=63072000; preload', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; 
mode=block', 'Atl-Traceid': '8fa4c1f91d6f9fe1', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group":
"endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": 
true, "max_age": 600, "report_to": "endpoint-1"}', 'Transfer-Encoding': 'chunked'}
response text = {"errorMessages":[],"errors":{"issuetype":"Specify an issue type"}}

请看看如何解决这个错误

如果你看一下错误,你可以看到它写着:

error ":{"issuetype":"指定问题类型"}

所以很明显,你设置issuetype的方式一定有问题。


你试过看API文档吗?你可以试试:

  • 通过issuetypeNames参数指定问题类型,而不仅仅是issuetype;或
  • 应该指定Issue Type ID,而不是Issue Type name。

请注意,在Jira中,问题类型可以自定义,因此您尝试创建的问题类型可能并不总是存在/具有相同的名称。您可以尝试获取用户的所有问题类型,看看情况是否如此。

最新更新