Create issue in a Remote JIRA instance from another JIRA using REST API

I am trying to create a JIRA issue from one JIRA instance to the other using JIRA API. I am using

groovy. This code works perfectly fine when I run it from intellijIDEA , when I run the same code in scriptrunner console, it doesnt throw any error and never creates the issue. could anyone help please.

I mean create issue in another remote JIRA instance from a local JIRA instance using 
scriptrunner postfunction.

//code starts here-----------------------------------------------------

import groovy.json.StreamingJsonBuilder

def baseURL = "";
def authString = "admin:*****".getBytes().encodeBase64().toString();

def body_req = [
"fields": [
"key": "AOBD"
"summary": "REST Test",
"issuetype": [
"name": "Task"

URL url = new URL(baseURL);
HttpURLConnection connection=(HttpURLConnection)url.openConnection();
connection.setRequestProperty( "Authorization", "Basic ${authString}" );
connection.requestMethod = "POST";
connection.doOutput = true;
connection.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
connection.outputStream.withWriter("UTF-8") { new StreamingJsonBuilder(it, body_req) }

//code ends here------------------------------

Thank you

1 answer

You calling the wrong URL for REST API create issue to start with.


Hi Niclas,

Thank you very much for your response.

I changed the URL from to "

but it still doesnt work. Basically I replaced "latest" with "2" . is that correct?


Thank you

You can find plenty of examples here. Make sure it works with cURL first.

Your payload seem to [] instead of expected {}.

Br, Niclas



In addition to what Niclas has said, if you have an application link setup between both you're best off using that. There's some examples of how to do that to intregrate between Atlassian application using ScriptRunnner here:

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Apr 17, 2018 in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

798 views 2 19
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you