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

JiraPS模块New-JiraIssue创建Jira工单报错排查及解决方案

JiraPS PowerShell模块New-JiraIssue创建工单报错解决方案

遇到的报错

报错1:自定义字段与components字段校验失败

调用New-JiraIssue时触发如下错误:

Invoke-JiraMethod : 
customfield_10806 components 
----------------- ---------- 
Could not find valid 'id' or 'value' in the Parent Option object. data was not an array

对应初始错误脚本如下:

New-JiraSession -Credential $Credentials -Verbose #-Debug
$field = @{
'components' = @{
id = 10303
}
'customfield_10806' = @{
id = 10704
}
}
New-JiraIssue -Project 'PROJECT' -IssueType '4' -Fields $field -Summary "Test Summary Created by $($env:username) in PowerShell" `
-Description "Test Summary Created by $($env:username) in PowerShell" -Reporter 'REPORTER' -Verbose -Confirm:$false

报错2:优先级字段无法设置

添加-priority 4参数后触发如下错误:

Invoke-JiraMethod : 
priority 
-------- 
Field 'priority' cannot be set. It is not on the appropriate screen, or unknown.

根因说明

  • components字段在Jira接口要求中必须传入数组格式,初始写法直接传入单个哈希表,不符合参数规范
  • 自定义字段customfield_10806为下拉单选类型,接口要求传选项的value(即选项显示名称),不能直接传id值
  • 优先级字段报错是因为当前创建工单使用的IssueType对应的创建界面,未配置优先级字段,要么在Jira后台将优先级字段添加到对应界面,要么创建时不传该参数

正确可运行脚本

New-JiraSession -Credential $Credentials -Verbose
$fields = @{
    Project = 'PROJECT'
    IssueType = 4
    Summary = "Test Summary Created by $($env:username) in PowerShell"
    Description = "Test Summary Created by $($env:username) in PowerShell"
    Reporter = 'REPORTER'
    Fields = @{
        'customfield_10806' = @{'value' = 'Low'}
        Components = @(
        @{
            name = 'NAME'
        })
        }
}
New-JiraIssue @Fields -Verbose

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.28 11:54:01