Forums

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

How to change status using scriptrunner with post API?

Rogerio
Contributor
December 18, 2023

Hi everybody,

 

I tried to change a status using scriptrunner and Post API... But return error.

My script is as 

// }
def result2 = post("/rest/api/3/issue/${issue.key}/transitions")
.header('Content-Type', 'application/json')
.body(
transition: [
"id": newStatusId
]
)
.asString()

But It doesnt work.

1 answer

1 accepted

1 vote
Answer accepted
Kristian Walker _Adaptavist_
Community Champion
December 19, 2023

Hi Rogerio,

 

I can confirm we have an example in the documentation here that shows how to transition an issue.

I can confirm I have tested this, and it works as expected as long as the transition Id specified is a valid transition in the workflow that could be made through the UI, as only valid transitions that users can make in the UI can be done via a script as well.

I hope this helps.

Regards,

Kristian

Rogerio
Contributor
December 19, 2023

Hi Kristian, 

How are you? Thank you for your help. 

I did a adjustment but It doesn't work. Returned to me. 

 

error.jpg

Do you have idea? 

I am administrator in the project. So, I don't understand it.

Kristian Walker _Adaptavist_
Community Champion
December 19, 2023

Hi Rogerio,

This error indicates that there are some required fields or there are some validators that control who can handle the issue.

The API will only allow the issue to be transitioned if all required fields have values and if the script user has permission to transition the issue. 

If the issue cannot be transitioned in the UI, then it will not be able to be transitioned by the Script, so you should ensure the problem can be transitioned in the UI first before using the script.

Regards,

Kristian

Rogerio
Contributor
December 20, 2023

Hi Kristian,

 

I did do a fix in the script and It worked.

 

Thank you so much!!!

 

Kind regards,

 

Rogério

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events