JiraPs Powershell Module Code error

Christopher September 9, 2022

I'm attempting to create a new Jira issue using the powershell code below and I keep getting the error at the bottom.  I can't seam to find what I'm doing wrong.  

 

$cred = mycredential

set-jiraconfigserver -Server "https://myserver.atlassian.net"
get-jiraissue -Issue "DEV-251" -Credential $cred

Get-JiraIssueCreateMetadata -Project DEV -IssueType Task -Credential $cred | ? {$_.Required -eq $true}

#customfield_10029 = @{self=https://myserver.atlassian.net/rest/api/2/customFieldOption/10231; value=DatabaseQueue; id=10231},
$fields = @{
'components' = (
'Century Distribution Systems, Inc.'
)
'customfield_10029' = (
id=1023
)
}
New-JiraIssue -Project "DEV" -IssueType "Task" -Summary "Test for backup automation" -Description "Test for backup automation" -Reporter "creffner@cds-net.com" -Labels "Maintenance:Refactoring" -Parent "DEV-2062" -Credential $cred -Fields $fields -verbose

error returned:

Invoke-JiraMethod :
components customfield_10029
---------- -----------------
Specify the value for components in an array Specify a valid 'id' or 'name' for Department
At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.9.0\JiraPS.psm1:3603 char:27
+ if ($result = Invoke-JiraMethod @parameter) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
+ FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod

 

I can see from the output of get-jiraissuecreatemetadata  that customfield_10029 is the Department field. and I"m using one of the ids that is returned as an allowed value.

Id : customfield_10029
Required : True
AllowedValues : {@{self=https://myserver.atlassian.net/rest/api/2/customFieldOption/10228; value=BIOperations; id=10228},
@{self=https://myserver.atlassian.net/rest/api/2/customFieldOption/10232; value=DatabaseRelease; id=10232},
@{self=https://myserver.atlassian.net/rest/api/2/customFieldOption/10231; value=DatabaseQueue; id=10231},
@{self=https://myserver.atlassian.net/rest/api/2/customFieldOption/10049; value=DataWarehouse; id=10049}...}
Operations : set
HasDefaultValue : False
Name : Department
Schema : @{type=option; custom=com.atlassian.jira.plugin.system.customfieldtypes:select; customId=10029}
key : customfield_10029

 

1 answer

0 votes
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 14, 2023

Hi @Christopher  - Did you ever get this sorted out? Can you provide what you ended up doing? 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events