Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating JIRA issue using curl from command line

Tags:

rest

curl

jira

I've been through documentation here according to which I'm creating a issue for JIRA . I know I'm making some terribly small mistake . I'm trying to create a new JIRA request from command line (later I'll integrate in my java code) From my Mac terminal I'm trying to run :

    curl -D- -u username:password -X POST --data {"fields":{"project":{"key": “PROJECTKEY"},"summary": "REST ye merry gentlemen.","description": "Creating of an issue using project keys and issue type names using the REST API","issuetype": {"name": "Bug"}}} -H "Content-Type: application/json" https://mycompanyname.atlassian.net/rest/api/2/issue/

I believe this has something to do with the "data". Thanks in advance. The example has been taken from the documentation link itself.

OUTPUT : I'm getting nothing in my terminal, no error, no expected output .

PROJECTKEY is taken from the KEY column from the All Project list in my DASHBOARD.

like image 406
lazy rabbit Avatar asked Jun 25 '15 14:06

lazy rabbit


People also ask

How do I create a JIRA issue with REST API?

Creating an issue using the Jira REST API is as simple as making a POST with a JSON document. To create an issue, you will need to know certain key metadata, like the ID of the project that the issue will be created in, or the ID of the issue type.

What is cURL API command?

cURL, which stands for client URL, is a command line tool that developers use to transfer data to and from a server. At the most fundamental, cURL lets you talk to a server by specifying the location (in the form of a URL) and the data you want to send.


1 Answers

Two things are off:

  1. you need to put the data that you want to post in quotes
  2. the first double quote surrounding PROJECT_KEY is a unicode character instead of a regular double quote, so change “PROJECTKEY" to "PROJECTKEY"

This should work:

curl -D- -u username:password -X POST --data '{"fields":{"project":{"key": "PROJECTKEY"},"summary": "REST ye merry gentlemen.","description": "Creating of an issue using project keys and issue type names using the REST API","issuetype": {"name": "Bug"}}}' -H "Content-Type: application/json" https://mycompanyname.atlassian.net/rest/api/2/issue/
like image 80
Hans Z. Avatar answered Oct 18 '22 22:10

Hans Z.