I am unable to create a variable on this request so I can later convert the variable to JSON using converttojson
{
"update": {
"comment": [
{
"add": {
"body": "Comment added when resolving issue"
}
}
]
},
"transition": {
"id": "21"
}
}
Tried the below
$jsonRequest = @{
update= @{
comment =@{
add =@{
body = "$Description"
}
}
}
transition =@{
id = $TransactionID
}
}
But get an output as below
{
"transition": {
"id": 1
},
"update": {
"comment": {
"add": "System.Collections.Hashtable"
}
}
}
Comment" in your JSON is a list containing a hashtable, in your code it's a hashtable containing a hashtable.
This looks right by making it an array of one item:
$jsonRequest = [ordered]@{
update= @{
comment = @(
@{
add =@{
body = "$Description"
}
}
)
}
transition = @{
id = 21
}
}
$jsonRequest | ConvertTo-Json -Depth 10
And I've made it '[ordered]' so the update and transition come out in the same order as your code, although that shouldn't really matter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With