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

Sandhya Varanasi April 27, 2015

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 votes
Sandhya Varanasi April 27, 2015

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



 

Ajit Dash May 28, 2020

Hi Team,

Could you please share the undocumented REST API url for creation of jira issue. 

The way it is available for the project creation: 

POST /rest/project-templates/1.0/createshared/{0}

Similarly what is the undocumented REST API for the issue creation. 

 

Note:  I have tried with the below option, getting 401. So looking for the alternate approach as described above for the project creation

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/

 

Reference link for undocumented REST API: 

https://community.atlassian.com/t5/Answers-Developer-Questions/Create-new-Project-via-REST-based-on-existing-Project/qaq-p/527104 

0 votes
João Palharini
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 27, 2015

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

0 votes
Pedro Cora
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 27, 2015

Suggest an answer

Log in or Sign up to answer