I'm trying to call a Zendesk API from a ScriptRunner script listener. Is this even possible? Based on what I've found in forums, I've tried the HTTPBuilder and also tried the RESTClient. Both options fail and are unable to find the "addRequestInterceptor" and "request" methods. I'm new to this and at a loss. What am I missing?
import groovyx.net.http.RESTClient;
import groovyx.net.http.HTTPBuilder;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.protocol.HttpContext;
def RESTClient http;
def baseUrl = "https://{}.zendesk.com/";
http = new RESTClient(baseUrl);
http.client.addRequestInterceptor(new HttpRequestInterceptor() {
void process(HttpRequest httpRequest, HttpContext httpContext) {
httpRequest.addHeader('Authorization', 'Basic ' + '{user}:{pwd}'.bytes.encodeBase64().toString())
}
})
def issue = http.request(POST, JSON) {
uri.path = '/api/v2/tickets/81513.json'
}