Hi there. I’m having quite a bit of trouble with the following endpoint within the Jira Assets API.
https://api.atlassian.com/jsm/assets/workspace/{workspaceId}/v1/object/create
I’m writing a PowerShell script that would create an object within my specified object type, and I keep getting back a strange character: â.
By default, my PowerShell instance uses OEM encoding, and I added [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 at the top to force to use WTF - still didn’t work.
This is my try/catch. Let me know if there’s any additional information needed or if you can help me out.
$Body = @{
"objectTypeId" = $ObjectTypeID
"attributes" = @(
@{
"objectTypeAttributeId" = "310"
"objectAttributeValues" = @(@{ "value" = "Hello" }) # Server name/ID - type: String
},
@{
"objectTypeAttributeId" = "348"
"objectAttributeValues" = @(@{ "value" = ${OS} }) # OS - type: Object
},
@{
"objectTypeAttributeId" = "344"
"objectAttributeValues" = @(@{ "value" = "[Description]" }) # Description - type: String
},
@{
"objectTypeAttributeId" = "345"
"objectAttributeValues" = @(@{ "value" = ${OwnerID} }) # Owner (can have multiple owners by re-copying the attribute { }) - type: Object
},
@{
"objectTypeAttributeId" = "400"
"objectAttributeValues" = @(@{ "value" = "[Subnet]" }) # Subnet - type: String
},
@{
"objectTypeAttributeId" = "401"
"objectAttributeValues" = @(@{ "value" = ${NetworkID} }) # Vnet - type: Object
},
@{
"objectTypeAttributeId" = "402"
"objectAttributeValues" = @(@{ "value" = "[Subscription]" }) # Subscription - type: String
},
@{
"objectTypeAttributeId" = "403"
"objectAttributeValues" = @(@{ "value" = "[Resource Group]" }) # Resource Group - type: String
}
)
} | ConvertTo-Json -Depth 10
try {
$Response = Invoke-RestMethod -Uri $JiraAssetsURL -Headers $Headers -Method Post -Body $Body
Write-Host "Success! Object Updated:"
$Response | ConvertTo-Json -Depth 10
} catch {
Write-Host "HTTP Status Code: $($_.Exception.Response.StatusCode)"
}