Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,368,772
Community Members
 
Community Events
168
Community Groups

JiraPs Powershell Module Code error

Edited

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

 

0 answers

Suggest an answer

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

Atlassian Community Events