Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

How to make API calls to custom end points using Exalate?

 
1
0
-1

1 answer

  1.  
    1
    0
    -1

    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

      CommentAdd your comment...