Using rest API how do i create a ticket in JIRA? What are the steps?

Hi

Trying to use CURL to post the tickets into JIRA system.

 

I used GET which works fine but the POST seems to have issue

GET

curl -D- -u svaranasi.sv@gmail.com:testing123 -X GET -H "Content-Type: application/json" http://localhost:8080/rest/api/2/search?jql=assignee=Sandhya

POST

curl -D- -u svaranasi.sv@gmail.com:testing123 -X POST -H "Content-Type: application/json" --data { "fields": {"project":{ "key": "TEST" },"summary": "REST ye merry gentlemen.","description": " REST API","issuetype": {"name": "Bug" } }} http://10.1.132.48:8080/rest/api/2/issue/

 

Thanks

Sandhya

3 answers

0 vote

Hi Sandhya!

First, you'll have to make sure the Project mentioned in the curl command exists on the instance as well as the Issue Type. In a template Service Desk project at my local staging instance, the following command worked just fine:

curl -D- -u user:password -X POST -H "Content-Type: application/json" --data '{ "fields": {"project":{ "key": "JS" },"summary": "REST ye merry gentlemen.","description": " REST API","issuetype": {"name": "IT Help" } }}' http://localhost:8080/rest/api/2/issue/

information Note that I surrounded the --data arguments with simple quotes as well.

If you are still unable to proceed, please specify the error message thrown out by JIRA.

--
Cheers!

Joao

Hi

Thank you! 

The below command works fine.  

curl -D- -u xyz@gmail.com:testing123 -X POST --data @/data.txt -H "Content-Type: application/json" http://a.b.c.d:8080/rest/api/2/issue/ 

data.txt

{
"fields":{
"project": {"key": "test"},
"summary": "REST",
"description": "REST 2",
"issuetype": { "id": "3" }
}
}

While trying to have JIRA as an output to logstash using logstash-output-jira plugin that uses jiralicious 0.2.2, I get the below error after starting logstash to create ticket. What is the best jiralicious version that could be used which has resolution for this kind of issue.

Please redirect me to right forum if needed. 

Errno::ECONNREFUSED: Connection refused - Connection refused

 

initialize at org/jruby/ext/socket/RubyTCPSocket.java:126
open at org/jruby/RubyIO.java:1177
connect at /opt/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:763
timeout at org/jruby/ext/timeout/Timeout.java:104
connect at /opt/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:763
do_start at /opt/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:756
start at /opt/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:745
request at /opt/logstash/vendor/jruby/lib/ruby/1.9/net/http.rb:1293
perform at /opt/logstash/vendor/bundle/jruby/1.9/gems/httparty-0.11.0/lib/httparty/request.rb:92
perform_request at /opt/logstash/vendor/bundle/jruby/1.9/gems/httparty-0.11.0/lib/httparty.rb:461
post at /opt/logstash/vendor/bundle/jruby/1.9/gems/httparty-0.11.0/lib/httparty.rb:414
request at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/session.rb:29
login at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/cookie_session.rb:60
before_request at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/cookie_session.rb:20
request at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/session.rb:28
fetch at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/base.rb:92
create at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/issue.rb:96
save at /opt/logstash/vendor/bundle/jruby/1.9/gems/jiralicious-0.2.2/lib/jiralicious/issue.rb:196
receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-jira-0.1.4/lib/logstash/outputs/jira.rb:99
handle at /opt/logstash/lib/logstash/outputs/base.rb:88
initialize at (eval):27
call at org/jruby/RubyProc.java:271
output at /opt/logstash/lib/logstash/pipeline.rb:279
outputworker at /opt/logstash/lib/logstash/pipeline.rb:235
start_outputs at /opt/logstash/lib/logstash/pipeline.rb:163



 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

627 views 3 11
Read article

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