1
0
-1

Greetings,


I'm trying to get an issue based on an specific field by using the /rest/api/3/search call, but I get null all the time.


Basically the line is:

def localIssue = httpClient.get("/rest/api/3/search?jql=cf[11201]~"+replica.RITM?.number)


I also tried a simple /rest/api/3/issue call, just like the example in https://docs.idalko.com/exalate/display/ED/How+to+make+any+Jira+Cloud+REST+API+call+with+the+Jira+Cloud+HTTP+client , and also got null:


def localIssue = httpClient.get("/rest/api/3/issue/{issueKey}") 

(I'm passing directly an existant issueKey in the line above, not using a variable)


I also tried using both calls directly in the browser and I could retrieve the issue/s data without a problem.


So, it seems that I can't get any data from exalate using the REST api.


I did check that I have "Project Role (atlassian-addons-project-access)" in the Browse Projects permission for the project I'm searching in, also the issues I'm searching are already exalated, so exalate can see them.


Anyone would know if I'm doing something wrong in the get calls that I wasn't aware of or something I'm not seen?


Kind regards,
Alvaro

  1. Ariel Aguilar

    Hi Alvaro,

    There is a simple way for you to check if the data is retrieved:

    You can add to the incoming script:


    def localIssue = httpClient.get("/rest/api/3/issue/AE-11743")
    debug.error(localIssue)  

    Could you provide what error is generated on the error stack trace?

    Kind regards,

    Ariel

  2. Alvaro Jardon

    Hi Ariel,


    Using the provided script, the error is :

    No signature of method: com.exalate.hubobject.jira.DebugHelper.error() is applicable for argument types: (scala.collection.convert.Wrappers$MapWrapper) values: [[self:https://blablabla.atlassian.net/rest/api/3/issue/66527, ...]] Possible solutions: error(java.lang.String), every(), grep(), iterator(), macro(groovy.lang.Closure), print(java.lang.Object)


    So, I see the httpClient.get() is not giving an http response, but a scala mapwrapper.


    Using instead:

    debug.error(localIssue.toString())

    returns the response in string format.


    So I tried:

    def getCall = "/rest/api/3/search?jql=cf[11201]~${replica.RITM?.number}"
    debug.error(getCall)


    and it gives correctly:


    Sync rules error
    /rest/api/3/search?jql=cf[11201]~RITM6397855

    (just to test the RITM was being passed correctly to the get call)


    using that call in a browser gives the correct data.


    and finally with:

    def getCall = "/rest/api/3/search?jql=cf[11201]~${replica.RITM?.number}"
    def localIssue = httpClient.get(getCall)
    debug.error(localIssue?.toString())


    throws a

    Sync rules error
    com.exalate.api.exception.IssueTrackerException


    Error Stack Trace
    com.exalate.api.exception.script.IssueTrackerScriptException: com.exalate.api.exception.IssueTrackerException at com.exalate.error.services.ScriptExceptionCategoryService.$anonfun$categorizeProcessorAndIssueTrackerExceptionsIntoScriptExceptions$1(ScriptExceptionCategoryService.scala:31) at com.exalate.error.services.ScriptExceptionCategoryService.$anonfun$categorizeProcessorAndIssueTrackerExceptionsIntoScriptExceptions$1$adapted(ScriptExceptionCategoryService.scala:27) at scala.collection.immutable.Stream.foreach(Stream.scala:533) at com.exalate.error.services.ScriptExceptionCategoryService.categorizeProcessorAndIssueTrackerExceptionsIntoScriptExceptions(ScriptExceptionCategoryService.scala:27) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:57) at com.exalate.replication.services.processor.ChangeIssueProcessor.$anonfun$executeScriptRules$1(ChangeIssueProcessor.scala:136) at scala.util.Try$.apply(Try.scala:213) at com.exalate.replication.services.processor.ChangeIssueProcessor.executeScriptRules(ChangeIssueProcessor.scala:134) at com.exalate.replication.services.processor.ChangeIssueProcessor.$anonfun$changeIssue$7(ChangeIssueProcessor.scala:96) at scala.concurrent.Future.$anonfun$flatMap$1(Future.scala:307) at scala.concurrent.impl.Promise.$anonfun$transformWith$1(Promise.scala:41) at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:64) at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:56) at akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:93) at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23) at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:85) at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:93) at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:48) at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:48) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183) Caused by: javax.script.ScriptException: javax.script.ScriptException: com.exalate.api.exception.IssueTrackerException at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:158) at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264) at com.exalate.processor.ExalateProcessor.execute(ExalateProcessor.java:98) at com.exalate.processor.ExalateProcessor.executeProcessor(ExalateProcessor.java:55) ... 19 more Caused by: javax.script.ScriptException: com.exalate.api.exception.IssueTrackerException at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155) ... 22 more Caused by: com.exalate.api.exception.IssueTrackerException at com.exalate.hubobject.jira.DebugHelper.error(DebugHelper.scala:16) at com.exalate.hubobject.jira.DebugHelper.error(DebugHelper.scala:13) at com.exalate.api.hubobject.jira.IDebugHelper$error.call(Unknown Source) at Script154.run(Script154.groovy:163) at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ... 23 more


    Kind regards,
    Alvaro

CommentAdd your comment...

1 answer

  1.  
    3
    2
    1

    Using the following call:

    def localIssue = new JiraClient(httpClient).http("GET", "/rest/api/3/search", ["jql":["cf[11201]~${replica.RITM?.number}"]], null, [:])  { response ->
        if (response.code >= 300 && response.code != 404) {
            throw new com.exalate.api.exception.IssueTrackerException("Failed to perform the request GET /rest/servicedeskapi/request/${issue.id}/feedback (status ${response.code}), and body was: \n\"${response.body}\"\nPlease contact Exalate Support: ".toString() + response.body)
        }
        if (response.code == 404) {
            return null
        }
        def txt = response.body as String
        def js = new groovy.json.JsonSlurper()
        js.parseText(txt)
    }
    debug.error(localIssue?.toString())


    I got the error:

    Unable to perform the request GET /rest/api/3/search with body: ```null``` , please contact Exalate Support: class org.codehaus.groovy.runtime.GStringImpl cannot be cast to class java.lang.String (org.codehaus.groovy.runtime.GStringImpl is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')


    The method isn't accepting GStrings.

    Making the following change:

    def jql = "cf[11201]~${replica.RITM?.number}".toString()
    def localIssue = new JiraClient(httpClient).http("GET", "/rest/api/3/search", ["jql":[jql]], null, [:])  { response ->
        if (response.code >= 300 && response.code != 404) {
            throw new com.exalate.api.exception.IssueTrackerException("Failed to perform the request GET /rest/servicedeskapi/request/${issue.id}/feedback (status ${response.code}), and body was: \n\"${response.body}\"\nPlease contact Exalate Support: ".toString() + response.body)
        }
        if (response.code == 404) {
            return null
        }
        def txt = response.body as String
        def js = new groovy.json.JsonSlurper()
        js.parseText(txt)
    }
    debug.error(localIssue?.toString())


    I'm finally getting the expected data.

      CommentAdd your comment...