Skip to content

JIRA v6.4

Jay edited this page Feb 28, 2019 · 10 revisions

Connecting to JIRA RESTful API

Jira Basic Authentication

Jira's Basic Authentication involves sending Base64 encoded string of form username:password

We need to create a http-header named Authorization of following form

"Authorzation: Basic [(BASE 64 encoded value of)username:password]"

base64 encode:

echo -n 'username:password' | base64

base64 decode:

echo 'c3VwZXJtYW46c3VwZXJwb3dlcg==' | base64 -D

Calling JIRA RESTful API and returning JIRA Project Workflow

Jira 6.4 REST API Docs

Following are examples of some APIs which work without Authentication

HTTP Method URL
GET https://[jira-url]/rest/api/2/dashboard
GET https://[jira-url]/rest/api/latest/issue/Jira-1234?expand=names,renderedFields
GET https://[jira-url]/rest/menu/latest/appswitcher

Following API can be used to fetch workflow details of a Jira project.

HTTP Method URL Auth
GET https://[jira-url]/api/2/project/{projectIdOrKey}/statuses Is required

For all the JIRA calls Postman was used and Basic Auth was used in the header of the call.

JIRA 6.4 REST API Documentation

Get a list of all the JIRA issues for a specific JIRA project

⚠️ JIRA api only supports returning a maxResults parameter as described in their api documentation. In order for the api to return more (or less) would require a change to the JIRA settings by an admin. Default maxResults is 50. Parameter in the URL maxResults returned is defaulted to 1000 issues returned.

HTTP Method URL
GET https://<jira.local>/rest/api/2/search?jql=<string>&maxResults=<integer>&startAt=<integer>&fields=<string>,<string>&expand=<string>,<string>
POST https://<jira.local>/rest/api/2/search BODY { "jql":"<string>","maxResults":<integer>,"startAt:<integer>,"expand":["<string>"],"fields":["<string>"]}
Parameter Description
jql=<urlEncode string> JIRA's JQL to send to the endpoint
maxResults=<number> Number of results to return for each call. Defalut 50 max 1000
expand=<string>,<string>,... options to choose from are: operations,editmeta,changelog,transitions,renderedFields
fields=<string>,<string>... fields to return from the api call (e.g. fields=summary,labels,project,issuetype)

To get the history of workflow status changes make sure to add the parameter of expand=changelog to the REST api call.

Extract, Transform, Load

⚠️ The fields below is an example of desired JIRA fields from the work item that should map to the domain. Each system could have a different mapping depending on how users are using JIRA. See Extract, Transform, Load (ETL) wiki page for more information about all field mappings.

Field JIRA Field
key issues[].key
title issues[].fields.parent.fields.summary
workType issues[].fields.issuetype.name
project issues[].fields.labels[]
service issues[].fields.project.name
classOfService issues[].fields.labels[]
statuses[] GIVEN: issues[].changelog.histories[].items[]field === "status" THEN: [ { created: issues[].changelog.histories[].created, fromStatus: issues[].changelog.histories[].items[].fromString, toStatus: issues[].changelog.histories[].items[].toString }, ... ]
dueDate issues[].fields.duedate