Atlassian Jira REST API

4 August 2017

Atlassian Jira is a propriety issue tracking software developed by Atlassian which provided provides bug tracking, issue tracking, and project management functions.According to Atlassian, Jira is used for issue tracking and project management by over 25,000 customers in 122 countries around the globe.Jira is written in Java and uses the Pico inversion of control container, Apache OFBiz entity engine, and WebWork 1 technology stack.The main features of Jira for agile software development are the functionality to plan development iterations, the iteration reports and the bug tracking functionality.[1]

In this post we will focus on important REST API and JQL Query provided by Jira as given in [3]. These REST API are popular API which helps to find metadata relate to Jira Project .For simplicity i will be taking [2] as the base Jira URL for all the APIs.All of the API will give a JSON response when used a tool like POST or posted in browser .But make sure that you login to the Jira instance first before making these calls.

Let BASE_URL =https://jira.atlassian.com/ 

Get Issue Details

This is GET request which will give details of all the issues in json Formal

<Base URL>/rest/api/2/issue/<Issue Number>

Example :
https://jira.atlassian.com/rest/api/2/issue/JRASERVER-65722

Below is the shortened version JSON Response of this call

{
  "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
  "id": "825975",
  "self": "https://jira.atlassian.com/rest/api/2/issue/825975",
  "key": "JRASERVER-65722",
  "fields": {
    "customfield_16730": {
      "self": "https://jira.atlassian.com/rest/api/2/customFieldOption/13930",
      "value": "Other",
      "id": "13930"
    },
    "fixVersions": [],
    "resolution": null,
    "versions": [],
    "issuelinks": [],
    "assignee": null,
    "status": {
      "self": "https://jira.atlassian.com/rest/api/2/status/1",
      "description": "Issue is open and has not yet been accepted by Atlassian.",
      "iconUrl": "https://jira.atlassian.com/images/icons/statuses/open.png",
      "name": "Open",
      "id": "1",
      "statusCategory": {
        "self": "https://jira.atlassian.com/rest/api/2/statuscategory/2",
        "id": 2,
        "key": "new",
        "colorName": "blue-gray",
        "name": "To Do"
      }
    },
    "customfield_16030": null,
    "components": [
      {
        "self": "https://jira.atlassian.com/rest/api/2/component/43417",
        "id": "43417",
        "name": "System Administration - General Configuration"
      }
    ]
  }
}

Get all Project Details of a Jira

<Base URL>/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields
Example :
https://jira.atlassian.com/rest/api/2/issue/createmeta?expand=projects.issuetypes.fields

Get all the metdata of particular project in Jira

<Base URL>/rest/api/2/issue/createmeta?projectKeys=<Project Key>&expand=projects.issuetypes.fields

Example :

https://jira.atlassian.com/rest/api/2/issue/createmeta?projectKeys=JRASERVER&expand=projects.issuetypes.fields

Get the value of particular Jira Custom Field using REST API

<Base url>/rest/api/2/issue/<Jira Issue>?fields=<Custom Field ID>
https://jira.atlassian.com/rest/api/2/issue/BSERV-9413/?fields=customfield_17130

It Gives a Json File as below which needs to be parsed to extract the custom fields value .

{
  "expand": "renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations",
  "id": "655478",
  "self": "https://jira.atlassian.com/rest/api/2/issue/655478",
  "key": "BSERV-9413",
  "fields": {
    "customfield_17130": {
      "self": "https://jira.atlassian.com/rest/api/2/customFieldOption/14432",
      "value": "Minor",
      "id": "14432"
    }
  }
}

Reference:

[1] https://en.wikipedia.org/wiki/Jira_(software)

[2] https://jira.atlassian.com/

[3] https://docs.atlassian.com/jira/REST/server/

Share: Twitter Facebook Google+ LinkedIn
comments powered by Disqus