I am new to working with PowerShell and trying to use JIRA's Rest API (without cURL-command) to update certain custom field like "Description". But I can not get the right way. Below is my code:
$body = {"update":
{"customfield_17526":
[
{
"set":
[
{ "description": "trying to use JIRA's Rest API to update custom field" }
]
}
]
}
}
Invoke-RestMethod -uri $restapiuri -Headers $Headers -Method PUT -ContentType
"application/json" -Body $body
What is wrong in the code above?
Thanks and regards
The problem was actually in the JSON format. In my case the parameter '$body' must be edited like following:
$body = @{
fields = @{
project = @{
key = "TEST"
}
summary = "Test summary
description = "Test description"
issuetype = @{
id = "123"
}
}
}
I came to this solution after multiple tries.
It is also very important to follow jira rules according the order of the fields, otherwise you get a 'bad request 400'.
Generally it is recommended to see some examples, as CraZ mentioned in his links or in this one: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/