Find linked issues to Epic through API

Narendra Kumar August 8, 2021

Hi Team, 

I'm trying to write script for Jira Cloud Scriptrunner where just want to get the issues linked with the Epic. 

But, I'm not able to see any linked issues result  when I'm passing the Epic Key. 

Any idea, what is an API which will return the linked issues to an Epic?

Please let me know if there is any query/concerns. Thanks!

Regards,

Narendra

 

1 answer

3 votes
Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2021

Hi @Narendra Kumar ,

if you want to search for issues, which are in Epic with key XYZ-1, you can use field Epic Link and JQL: "Epic Link" = XYZ-1

The same JQL I would you for search for issues REST API endpoint, see here.

Narendra Kumar August 9, 2021

Thanks @Hana Kučerová  for your reply. 

I'm writing the below code - 

def result2 = get('/rest/api/3/search?jql= Epic Link = JIR-765')
.header('Content-Type', 'application/json')
.asObject(Map)
return result2.body

But getting the below  error and there is no any result - 

io.github.openunirest.http.exceptions.UnirestException: java.net.URISyntaxException: Illegal character in query at index 124: https://us-west-2.in.argon.polaris.connect.product.adaptavist.com/proxy-service/rest/api/1/jira/proxy/rest/api/3/search?jql= Epic Link = JIR-765 at io.github.openunirest.request.UriFormatter.apply(UriFormatter.java:15) at io.github.openunirest.request.RequestPrep.getHttpRequest(RequestPrep.java:85) at io.github.openunirest.request.RequestPrep.prepareRequest(RequestPrep.java:29) at io.github.openunirest.request.HttpClientHelper.request(HttpClientHelper.java:29) at io.github.openunirest.request.BaseRequest.request(BaseRequest.java:92) at io.github.openunirest.request.BaseRequest.asObject(BaseRequest.java:147) at io.github.openunirest.request.BaseRequest$asObject.call(Unknown Source) at Script1.run(Script1.groovy:27) at Script1$run.call(Unknown Source) at Script1$run.call(Unknown Source) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:33) at com.adaptavist.sr.cloud.events.ScriptExecution.run(ScriptExecution.groovy:29) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at ConsoleScriptExecution1_groovyProxy.run(Unknown Source) Caused by: java.net.URISyntaxException: Illegal character in query at index 124: https://us-west-2.in.argon.polaris.connect.product.adaptavist.com/proxy-service/rest/api/1/jira/proxy/rest/api/3/search?jql= Epic Link = JIR-765 at org.apache.http.client.utils.URIBuilder.<init>(URIBuilder.java:81) at io.github.openunirest.request.UriFormatter.apply(UriFormatter.java:13) at io.github.openunirest.request.RequestPrep.getHttpRequest(RequestPrep.java:85) at io.github.openunirest.request.RequestPrep.prepareRequest(RequestPrep.java:29) at io.github.openunirest.request.HttpClientHelper.request(HttpClientHelper.java:29) at io.github.openunirest.request.BaseRequest.request(BaseRequest.java:92) at io.github.openunirest.request.BaseRequest.asObject(BaseRequest.java:147) at io.github.openunirest.request.BaseRequest$asObject.call(Unknown Source) at Script1.run(Script1.groovy:27) at Script1$run.call(Unknown Source) at Script1$run.call(Unknown Source) at com.adaptavist.sr.cloud.workflow.AbstractScript.evaluate(AbstractScript.groovy:33) at com.adaptavist.sr.cloud.events.ScriptExecution.run(ScriptExecution.groovy:29) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at ConsoleScriptExecution1_groovyProxy.run(Unknown Source) at com.adaptavist.sr.cloud.MainHandler.executeScript(MainHandler.groovy:388) at com.adaptavist.sr.cloud.MainHandler.processInput(MainHandler.groovy:334) at com.adaptavist.sr.cloud.MainHandler.access$0(MainHandler.groovy) at com.adaptavist.sr.cloud.MainHandler$_handleRequest_closure1.doCall(MainHandler.groovy:154) at 

 

 

ANy idea on this? 

Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2021

@Narendra Kumar I think the problem is there needs to quotes

/rest/api/3/search?jql="Epic Link"=JIR-765

JQL  is invalid without the quotes

Like Sai Avinash Duddupudi likes this
Narendra Kumar August 9, 2021

@Hana Kučerová  the above also not worked for me. Could you please check and confirm if it;s works for you? 

Thank you so much for your support. 

Hana Kučerová
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 9, 2021

Hi @Narendra Kumar ,

there's a nice example here in the library, navigate to Cloud code.

Pleas try.

Suggest an answer

Log in or Sign up to answer