Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

ScriptRunner RESTClient Help

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'

}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

65 views 0 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you