Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

external API call

Francesco Mazza September 20, 2018

From jira I need to make an external API call that gives me back the values that will be set in the issu fields. It's possible?

3 answers

1 vote
Tuncay Senturk
Community Champion
September 20, 2018

Also you can use free Easy Integrations app's post function.

Here you can see a brief documentation on how to do that.

1 vote
Nir Haimov
Community Champion
September 20, 2018

It is.

of course your source will have to have a rest api end point to call from to Jira.

Do you have Jira server or Cloud?

And, do you have ScriptRunner add-on? you will need this to make your rest call

Francesco Mazza September 20, 2018

I Have Jira Server

My source is a java web application that exposes calls REST API

I dont have ScriptRunner but I have Jira Misc Workflow Extensions can I do something with it or do I need ScriptRunner?

Nir Haimov
Community Champion
September 20, 2018

JMWE is good enough if you want to run your REST API call on transition (every time a speicific transition occur) you can do that with "Scripted (Groovy) operation on issue (JMWE add-on)" post-function.

If you want to run it one time from the admin add-on screen with "Groovy script tester".

In both options, you can write a groovy script, groovy is a script language based Java.

Francesco Mazza September 20, 2018

you can give me some examples.
You are very kind
Thank you

Nir Haimov
Community Champion
September 20, 2018

Sure :)

Here is a working example i use:

import org.apache.commons.httpclient.Credentials;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.commons.httpclient.auth.AuthScope;
import org.apache.commons.httpclient.methods.*;
import groovy.json.*

//rest api request
HttpClient client = new HttpClient();
GetMethod method = new GetMethod("your/rest/api/url...");
Credentials credentials = new UsernamePasswordCredentials("username","password");
client.getParams().setAuthenticationPreemptive(true);
client.getState().setCredentials(AuthScope.ANY, credentials);
client.executeMethod(method);
def response = method.getResponseBodyAsString()
method.releaseConnection();
0 votes
Francesco Mazza September 20, 2018

I try to change approach.
But first I need to know if there is a way to show a web form within a (particular) field on an issue. In practice I have a web link and I need to shoot the result in a field. It's possible?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events