Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Changing Status Using create issue API

Rajalakshmi Hariharan March 1, 2021

I am using the below payload. But its throwing error  "transitions": "Field 'transitions' cannot be set. It is not on the appropriate screen, or unknown." 

Could you please help resolve this ? 

POST Method

URL : rest/api/2/issue/

Payload : 

{
"fields": {
"project":
{
"key": "LRN"
},
"summary": "Sample TEst cases created using Jira API",
"description": "example of cucumber automated test - Scenario",
"issuetype": {
"name": "Test"
},
"priority" : { "name": "2-High"},
"customfield_24683": { "value": "Cucumber" },
"customfield_11040": { "value": "End to End Tests (E2E)"},
"customfield_26580" : { "value" : "ADFv2", "child" : { "value" : "API" } },
"customfield_10831" : { "value": "TestTeam"},
"transitions": [
{
"id": "11"

}
]
}
}

1 answer

0 votes
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2021

Hi @Rajalakshmi Hariharan 

Having answered as below, I re-read your question and it looks as though you're trying to create an issue and transition it in one go, which I'm not sure if you can do, create it then use another API call to transition it.

You haven't specified whether it's for cloud or server, my answer assumes cloud, although it shouldn't be that much different.

When I change a ticket's status, I use

{"update":{},"transition":{"id":"141"}}

Note the update which you don't have, I think that's important

and the actual API call that I use is

/rest/api/3/issue/ABC-123/transitions?expand=transitions.fields&transitionId=141

Of course, keep your transitionId number, for me 141 is to close a ticket

Rajalakshmi Hariharan March 2, 2021

Hi Warren,

Thanks for the response. I tried with Update as you suggested, now its creating the issue, but the status is not set.

{
"fields": {
"project":
{
"key": "LRN"
},
"summary": "SAmple TEst cases created using Jira API",
"description": "example of cucumber automated test - Scenario",
"issuetype": {
"name": "Test"
},
"priority" : { "name": "2-High"},
"customfield_24683": { "value": "Cucumber" },
"customfield_11040": { "value": "End to End Tests (E2E)"},
"customfield_26580" : { "value" : "ADFv2", "child" : { "value" : "API" } },
"customfield_10831" : { "value": "Leo"}

},
"update":{},
"transitions":
{
"id": "11"

}
}

 

Using the Get call for transitions the below are the list of transitions I got :

{
"expand": "transitions",
"transitions": [
{
"id": "11",
"name": "Start Progress",
"to": {
"self": "https://jira.com/rest/api/2/status/3",
"description": "'ASSIGNED'. This issue is being worked on by the assignee.",
"iconUrl": "https://jira.com/images/icons/statuses/inprogress.png",
"name": "In Progress",
"id": "3",
"statusCategory": {
"self": "https://jira.com/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
}
},
{
"id": "71",
"name": "Automate",
"to": {
"self": "https://jira.com/rest/api/2/status/12381",
"description": "",
"iconUrl": "https://jira.com/images/icons/statuses/generic.png",
"name": "Active",
"id": "12381",
"statusCategory": {
"self": "https://jira.com/rest/api/2/statuscategory/4",
"id": 4,
"key": "indeterminate",
"colorName": "yellow",
"name": "In Progress"
}
}
}
]
}

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 2, 2021

Hi @Rajalakshmi Hariharan 

I'm not clear whether you're doing this or not. You need to use 2 separate API calls - one to create the issue, and another to change the status.

I also notice that in your update JSON you're using transitions whereas it needs to be transition without the "s" at the end.

Rajalakshmi Hariharan March 4, 2021

Hi Warren,

I tried both transition and transitions, for both it didnt work.  I was trying to use create API to create and update in the same payload. Is it not possible to use same payload for create and update? 

should it be separate API call? 

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2021

Hi @Rajalakshmi Hariharan 

Yes, I don't believe that it can be done in 1 step, you will need to run 2 separate API calls

Rajalakshmi Hariharan March 4, 2021

Hi Warren, Thanks a lot. Its working with multiple API calls. Is there a way to do it in bulk ?

Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 4, 2021

Hi @Rajalakshmi Hariharan 

You haven't said how you're running these API calls - via code or Postman or something else. 

The easiest way to perform this procedure in bulk is via code. You have a loop for the number of issues that you want to create and run the 2 calls for each issue.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events