Hi,
I want to use ScriptRunner to control issue with REST APIs.
So I use " api/2/issue/{issueIdOrKey}/transitions " this REST API
Tried to run Issue's transition.
An error has occurred, but I don't know why.
Can You help me?
Thanks.
In addition, the final goal is to receive an issue key using REST endpoint to change the transition id of that issue.
test script :
import groovyx.net.http.RESTClient
import static groovyx.net.http.ContentType.JSON
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
import groovyx.net.http.HttpResponseException
@Grab (group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.5.0')
def client = new RESTClient('http://localhost:8080')
def jsonObj = new JsonSlurper().parseText('{"transition": {"id": "11"}}')
def response = client.post(path: "/rest/api/2/issue/CH-4/transitions?expand=transitions.fields",
contentType: JSON,
body: jsonObj,
headers: ['Content-Type': 'application/json; charset=UTF-8', 'Accept': 'application/json'])
error message :
groovyx.net.http.HttpResponseException:
at groovyx.net.http.RESTClient.defaultFailureHandler(RESTClient.java:263)
at groovyx.net.http.HTTPBuilder$1.handleResponse(HTTPBuilder.java:503)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:223)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:165)
at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515)
at groovyx.net.http.RESTClient.post(RESTClient.java:141)
at groovyx.net.http.RESTClient$post.call(Unknown Source)
at Script266.run(Script266.groovy:10)
Hi Jee.
I can help you out with this, if you are 100% sure that this is what want. To be honest, you really don't want to control issue transition through the REST API.
Using a post-function, or a listener, would be a lot easier, and it's functionality that you wouldn't have to code by yourself, since we've already provided that built-in.
These documentation articles might be of help:
This is the fast-track listener, that does precisely what you want based on a condition.
It is also available as a post-funciton, if I'm not mistaken.
Cheers!
Dyelamos
Thank you for your answers.
I wanted to change the state of issue on an external build tool, not on an Atlassian product.
Is it possible to change the state externally?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry let me make sure that I understand you.
You want to open a rest endpoint in your instance, that in turn accepts request from an external build tool to transition issues.
Is this correct?
Cheers
Dyelamos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's exactly what I want.
I've already solved it with curl.
Do you have any other ideas?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What I think you are doing now is setting a REST endpoint, and within that REST endpoint, you are yet making another call to the JIRA rest api.
Instead of using the rest api from within your REST endpoint, use a normal transition method via java. Like my colleague Aidan does here.
I would heavily suggest using this over calling a JIRA endpoint while within your own rest API. It would make use of less resources, and it would me more reliable.
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.