You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
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'
}