JiraPS - Set-JiraIssue, unexpected results

Rene Nielsen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 5, 2021

Context:

Using JiraPS module, latest, and PowerShell 5.1. On Windows platform.

I am implementing automated creation and updating of Jira Versions as well as Jira Issues. This is regarding updating a previously created Jira Issue using Set-JiraIssue.

Objective:

Update the DueDate field in an existing Jira Issue using Set-JiraIssue. Below is what I'm calling:

$parameters = @{
  Fields = @{
  DueDate = $NewDueDate
  }
}

Set-JiraIssue $parameters -Issue $JiraKey

 

*$NewDueDate is formatted as a string with -Format "MMMM d, yyyy"

Negative Outcome:

Even though I am only attempting to set the DueDate I am getting the Jira's Summary field value changed (as reflected through the Jira web UI) to the text "System.Collections.Hashtable". And the DueDate field is not updated.

Request:

Please advise where I am going wrong.

I am using calls to Set-JiraIssue elsewhere (but without the parameters & Fields API syntax). I am successfully using the parameters & Fields API syntax in conjunction with calls to New-JiraIssue. I am currently stumped as to where I am going astray here and searching for clues that might resolve my problem.

TIA

2 answers

0 votes
Rodd Heaton
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 29, 2022

Really late to the party, but figured I'd update since you both helped me figure it out. Looks  like instead of $parameters, use @parameters. This worked for me:

$j = Get-JiraIssue -Key "RTSAFSYSEN-2521"
$J.DueDate
2022-10-01
$parameters = @{Fields = @{DueDate = "2022-10-10"}}
Set-JiraIssue -key $j.key @parameters -WhatIf
What if: Performing the operation "Updating Issue" on target "RTSAFSYSEN-2521".
Set-JiraIssue -key $j.key @parameters
$j = Get-JiraIssue -Key "RTSAFSYSEN-2521"
$J.DueDate
2022-10-10
Maninder_Kaur April 17, 2024

Thanks a lot!

Using @ instead of $ solved my problem too. Your comment was a life saver for me, otherwise trying different syntaxes, restmethod, jira method etc drove me crazy lol. The command just needed a minor change lol. 

Like Rodd Heaton likes this
0 votes
Christopher Huckabee November 1, 2021

What format is the time/date in if you do a get-jiraissue?

Rene Nielsen
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 10, 2021

Sorry for the delayed response, just getting back to this issue.

The format returned for the jira issue DueDate is "yyyy-MM-dd", as in 2021-11-16.

Using the same date format doesn't seem to resolve my inability to update in this case.

See example below. Any insight(s) to resolve are appreciated.

Thanks

Example:

$j = Get-JiraIssue -Key "RM-4001"

$J.DueDate 

     2021-11-16

$parameters = @{Fields = @{DueDate = "2021-11-16"}}
$j | Set-JiraIssue -Fields $parameters -WhatIf
What if: Performing the operation "Updating Issue" on target "RM-4001".
$j | Set-JiraIssue -Fields $parameters
      Invoke-JiraMethod : An unknown error ocurred.
       At C:\Program Files\WindowsPowerShell\Modules\JiraPS\2.14.3\JiraPS.psm1:5509 char:21
       + Invoke-JiraMethod @parameter
       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       + CategoryInfo : InvalidResult: (:) [Invoke-JiraMethod], RuntimeException
       + FullyQualifiedErrorId : InvalidResponse.Status400,Invoke-JiraMethod

Suggest an answer

Log in or Sign up to answer