Hi,
i'm trying to transition an item to "Resolved" and everytime i get a HTTP 400 and i don't know why.
Can anybody give a hint what ist wrong with my json?
{
"update": {
"worklog": [{
"add": {
"started": "2018-10-02T06:00:00.000+0000",
"timeSpent": "1m"
}
}],
"comment": [{
"add": {
"body": "Bug has been fixed."
}
}]
},
"fields": {
"customfield_10636": {
"value": "yes"
},
"customfield_10533": [{
"add": {
"id": "10421"
}
}]
},
"resolution": {
"id": "10000"
},
"transition": {
"id": "5"
}
}
As mentioned in the documentation HTTP 400 means that the transition does not exist, but when i fetch the transition data i get 8601 as id for transition and 5 as id for transition.to.
My skript (powershell):
$servicedeskheaders = @{ Authorization = 'Basic AUTHHEADER'}
$proburl = "https://SERVER/rest/api/2/issue/ISSUE/transitions?expand=transitions.fields"
try
{
$transitiontotargetstatus='{"update":{"worklog":[{"add":{"started":"2018-10-02T06:00:00.000+0000","timeSpent":"1m"}}]},{"comment":[{"add":{"body":"Problem ist gefixt mit dem Release *EASY for Exchange 2.0.2* vom *06.09.2018*. [Download|https://extranet.easy.de/display/EASYforExchange/Downloads]"}}]},"fields":{"customfield_10636":{"value":"yes"},"customfield_10533":[{"add":{"id":"10421"}}],"resolution":{"id":"10000"}},"transition":{"id":"5"}}}'
$updatedissue = (Invoke-RestMethod -uri $proburl -Headers $servicedeskheaders -Method POST -Body $transitiontotargetstatus -ContentType "application/json").id
Write-Host ($updatedissue)
}
catch
{
$ErrorMessage = $_
Write-Error ($ErrorMessage)
}
AUTHHEADER, SERVER and ISSUE have to be replaced by basic authheader, jira server and issue.
Tested on https://jsonlint.com/ my json seems to be valid.
OK, i found out on my own.
Here is the solution:
The json has to look as follows:
{
"transition": {
"id": "8016"
},
"fields": {
"customfield_10533": [{
"id": "10421"
}],
"resolution": {
"id": "10000"
}
},
"update": {
"worklog": [{
"add": {
"started": "2018-10-08T13:38:45.000+0000",
"timeSpent": "1m",
"timeSpentSeconds": 60
}
}],
"comment": [{
"add": {
"body": "The Bug has been fixed"
}
}]
}
}
as you can see, "fields" works without "update" while "comment" and "worklog" needs it.
This took me days and grew me gray hairs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.