Originally asked by Dhiren Notani on 17 October 2024 (original question)
Answer by Dhiren Notani on 17 October 2024
You can do this via GroovyHttpClient within the outgoing and incoming sync scripts in Exalate.
Below is an example to do so.
def method = "GET"
def apiRoute = "https://eoo4591jwa8w4mz.m.pipedream.net?AAA=BBB"
def ghc = new GroovyHttpClient(httpClient)
def foo = ghc.http(
method,
apiRoute,
null,
["Authorization":["BASIC Zm9vOmJhcg=="]]
) { response ->
if (response.code >= 300 && response.code != 404) {
throw new com.exalate.api.exception.IssueTrackerException("Failed to perform the request $method ${apiRoute} (status ${response.code}), and body was: \n\"${response.body}\"\n".toString())
}
if (response.code == 404) {
log.debug("#groovyhttpclient $method ${apiRoute} responded with a 404")
return null
}
def txt = response.body as String
def js = new groovy.json.JsonSlurper()
js.parseText(txt)
}
A similar request can be done for POST/PUT/PATCH etc.
I hope this helps!
Thanks, Dhiren
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.