12

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.

lazy rabbit
  • 1,076
  • 3
  • 11
  • 29

1 Answers1

13

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/
Hans Z.
  • 50,496
  • 12
  • 102
  • 115
  • Z That was probably a mistake thanks.. But now I'm getting a error : {"errorMessages":["Version Found: Version Found is required."],"errors":{}} any help on this plss ?? – lazy rabbit Jun 25 '15 at 14:26
  • This works for me. JIRA is created but i do not get the JIRA number (ID) in the logs. Please let me know if i'm missing anything. – Yash Nov 20 '19 at 05:49
  • Essentially, i want to store the JIRA number in a variable which can be used in the scripts for other purposes. – Yash Nov 20 '19 at 10:37
  • Above syntax was working fine for me but suddenly I've started getting this error message: `curl: (3) [globbing] unmatched close brace/bracket in column 202`. What am i mssing? – Yash Jun 15 '20 at 09:58
  • @Yash Try using curl's `-g` or `--globoff` option. Check the man page. – rsaw Aug 26 '20 at 21:31