AtlassianPS / JiraPS

PowerShell module to interact with Atlassian JIRA
https://AtlassianPS.org/module/JiraPS
MIT License
321 stars 131 forks source link

Update Invoke-JiraIssueTransition.ps1 #417

Closed Rufus125 closed 4 years ago

Rufus125 commented 4 years ago

Increase the JSON transformation depth

Description

As can be seen by comparing the output of the last two commands, the "System.Collections.Hashtable" is not serialized and therefore the transition fails.

#create the fields object for a MultiGroupPicker/Multiselect/MultiUserPicker/VersionPicker field as can be found here: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#creating-an-issue-examples
$service = @(1)
$service_key_hashtable = @{key = 'JIRA-13961'}
$service[0] = $service_key_hashtable
$fields = @{customfield_12200 = $service}
ConvertTo-Json $fields #output just to compare it to the HTTP request
{
    "customfield_12200":  [
                              {
                                  "key":  "JIRA-13961"
                              }
                          ]
}

$newji = New-JiraIssue -Project "proj" -IssueType "Incident" -summary "summary"

$transition = $newji.Transition | where Name -eq "2nd level"

$resp = Invoke-JiraIssueTransition -Issue $newji -Transition $transition -Fields $fields -Verbose

ConvertTo-Json $requestBody -Depth 4
{
    "transition":  {
                       "id":  "113"
                   },
    "fields":  {
                   "assignee":  {
                                    "name":  null
                                }
               },
    "update":  {
                   "customfield_12200":  [
                                             {
                                                 "set":  [
                                                             "System.Collections.Hashtable"
                                                         ]
                                             }
                                         ]
               }
}

ConvertTo-Json $requestBody -Depth 5

{
    "transition":  {
                       "id":  "113"
                   },
    "fields":  {
                   "assignee":  {
                                    "name":  null
                                }
               },
    "update":  {
                   "customfield_12200":  [
                                             {
                                                 "set":  [
                                                             {
                                                                 "key":  "JIRA-13961"
                                                             }
                                                         ]
                                             }
                                         ]
               }
}

Motivation and Context

Types of changes

Checklist