how to create an issue in jira via rest api?

后端 未结 9 2272
北恋
北恋 2020-12-08 19:24

Is it possible to create an issue in jira using REST api? I didn\'t find this in the documentation (no POST for issues), but I suspect it\'s possible.

A wget or curl

相关标签:
9条回答
  • 2020-12-08 19:27

    As of the latest released version (4.3.3) it is not possible to do using the REST API. You can create issues remotely using the JIRA SOAP API.

    See this page for an example Java client.

    0 讨论(0)
  • 2020-12-08 19:29

    The REST API in JIRA 5.0 contains methods for creating tasks and subtasks.

    (At time of writing, 5.0 is not yet released, although you can access 5.0-m4 from the EAP page. The doco for create-issue in 5.0-m4 is here).

    0 讨论(0)
  • 2020-12-08 19:34

    POST to this URL

    https://<JIRA_HOST>/rest/api/2/issue/
    

    This data:

    {
    "fields": {
       "project":
       { 
          "key": "<PROJECT_KEY>"
       },
       "summary": "REST EXAMPLE",
       "description": "Creating an issue via REST API",
       "issuetype": {
          "name": "Bug"
       }
      }
    }
    

    In received answer will be ID and key of your ISSUE:

    {"id":"83336","key":"PROJECT_KEY-4","self":"https://<JIRA_HOST>/rest/api/2/issue/83336"}
    

    Don't forget about authorization. I used HTTP-Basic one.

    0 讨论(0)
  • 2020-12-08 19:34

    Now you can use REST + JSON to create issues.

    To check which json fields you can set to create the issue use: https://jira.host.com/rest/api/2/issue/createmeta

    For more information please see the JIRA rest documentation: https://docs.atlassian.com/jira/REST/6.2.4/

    0 讨论(0)
  • 2020-12-08 19:34

    Just stumbling on this and am having issues creating an issue via the REST API.

    issue_dict = {
        'project': {'key': "<Key>"},
        'summary': 'New issue from jira-python',
        'description': 'Look into this one',
        'issuetype': {'name': 'Test'},
    }
    new_issue = jira.create_issue(issue_dict)
    

    new_issue returns an already existing issue and doesn't create one.

    0 讨论(0)
  • 2020-12-08 19:36

    To answer the question more direct, i.e. using cURL.

    To use cURL to access JIRA REST API in creating a case, use

    curl -D- -u <username>:<password> -X POST --data-binary "@<filename>"  -H "Content-Type: application/json" http://<jira-host>/rest/api/2/issue/
    

    And save this in your < Filename> (please edit the field per your Jira case) and save in the folder you call the cURL command above.

    {
        "fields": {
           "project":
           { 
               "key": "<PROJECT_KEY>"
           },
           "summary": "REST EXAMPLE",
           "description": "Creating an issue via REST API",
           "issuetype": {
               "name": "Bug"
           }
       }
    }
    

    This should works. (note sometimes if it errors, possibly your content in the Filename is incorrect).

    0 讨论(0)
提交回复
热议问题