You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python创建Jira Issue遇HTTP 400错误:issuetype参数问题求助

Jira API创建工单触发HTTP 400错误(issuetype: Specify an issue type)的解决方法

问题场景

使用Python调用Jira API创建工单时,触发JIRAError HTTP 400错误,响应提示"issuetype: Specify an issue type"。

相关代码

from jira import JIRA
jira = JIRA(basic_auth=("soubhagyakumar666@gmail.com", "9uQ7ll78jq7AmY3Xh5ghF9A9"), options={"server": "https://soubhagyapradhan.atlassian.net"})

# Jira integration code
data = {
    "project":
    {
        "key": "TEST"
    },
    "summary": "REST ye merry gentlemen.",
    "description": "Creating of an issue using project keys and issue type names using the REST API",
    "issuetype": {
        "name": "Bug"
    }
}

res = jira.create_issue(fields=data)
print(res)

报错信息

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

response headers = {'Date': 'Thu, 10 Nov 2022 18:55:40 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'AtlassianEdge', 'Timing-Allow-Origin': '*', 'X-Arequestid': '99553b2ab107cf312060560b7e28c34f', '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': 'f18031aca50ee85e', '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"}}

排查与解决方法

1. 确认项目可用的问题类型

错误核心原因是指定的Bug类型在TEST项目中不存在,或名称存在拼写/大小写/空格差异。先通过代码获取项目支持的所有问题类型:

# 获取TEST项目的所有问题类型
project = jira.project("TEST")
issuetypes = jira.issue_types_for_project(project.id)
for it in issuetypes:
    print(f"问题类型名称: {it.name}, ID: {it.id}")

运行后,从输出中提取正确的问题类型名称或ID,替换到创建工单的参数中。

2. 改用问题类型ID(更可靠)

使用问题类型ID比名称更不易出错,可避免本地化名称、拼写差异等问题。修改data中的issuetype字段:

"data": {
    # ... 其他字段保持不变
    "issuetype": {
        "id": "10001"  # 替换为实际的Bug类型ID
    }
}

3. 检查权限与项目配置

确保当前账号拥有在TEST项目中创建对应类型工单的权限,同时确认该问题类型已关联到TEST项目(可在Jira后台项目设置中查看)。

内容的提问来源于stack exchange,提问作者soubhagya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 05:40:22