Answer by Alvaro Jardon on 16 November 2021
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.