CREATE ISSUE USING JSON OR JAVA/JAVASCRIPT

Hi,

Is it possible to create an issue through JSON-RPC? I checked the JIRA site

https://developer.atlassian.com/display/JIRADEV/JIRA+JSON-RPC+Overview' but was unable to infer anything to start with. I am new to JSON. Also I found that the JSON-RPC URL below is not responding when I hit it directly.

http://localhost:8080/jira/rpc/json-rpc/jirasoapservice-v2​ . Getting a 'Not found 404 error' .

Is there a step by step approach or can anyone help me in creating an issue in JIRA through JSON 
or JAVA/JAVASCRIPT code. 
Thanks in advance.

3 answers

Hi, which version of JIRA are you using? If REST/JSON to create issues you need JIRA 5.x. Refer to http://docs.atlassian.com/jira/REST/latest/ for the documentation.

I am using JIRA 5.1.4

It is hard to tell what your requirement is but createIssue can be used for automation needs.

Yes, I am planning to invoke createIssue API remotely where one of the need is for automation.

Not entirely JSON-RPC, but I was able to create new issues by sending some JSON code as a HTTP POST request:

Request to: http://my_jira_machine:7991/rest/api/2/issue/

An HTTP Authorization header was added with authentication details of an existing Jira user

HTTP ContentType header set to : "application/json"

Data, e.g. something as straightforward as:

'{ "fields": { "project": { "key": "' + ProjectCode + '" }, "summary": "' + Summary + '", "description": "' + Description + '", "issuetype": { "name": "Bug" } } }'

This was not from Javascript, but I guess it would be possible to do this using e.g. JQuery:

http://stackoverflow.com/questions/5570747/jquery-posting-json

http://api.jquery.com/jQuery.post/

Hope this helps! :)

Thanks Ethan. But when I execute it against my local JIRA instance, 'http://localhost:8081/rest/api/2/issue/' to check the availability, I am getting the following error

Unauthorized (401)

Encountered a 401 - Unauthorized error while loading this page.

The fact that you see a 401 means that at least there apparently is a site/API there to call.. an improvement over the 404 ;)

Are you sure that you are sending the correct authentication data?

My example works from Flash, where I added the headers in the following way:

// Authentication
var encoder:Base64Encoder = new Base64Encoder();
encoder.encode("username:password");
http.headers["Authorization"] = "Basic " + encoder.toString();

From Javascript you can do similar things. See for example:

http://stackoverflow.com/questions/5507234/how-to-use-basic-auth-and-jquery-and-ajax


Thanks. Also I would like to add an attachment(a word doc with requests) to the createISSUE call which I am sending to my JIRA local instance. How should I handle that?

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,117 views 13 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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot