Create issue and/or data with JSON REST API

Barry Pollard May 31, 2016

I would like to link JIRA up to an existing system to pull data in automatically.

I can think of two ways of doing this:

1) We click on a link in our existing system which sends a JSON REST API request to a HTTP endpoint on JIRA which raises an Issue in JIRA Software and sets some fields based on the JSON values we provide.

2) We open an issue manually type in JIRA, key in a reference number, and click a button which makes a JSON REST API request to a HTTP endpoint hosted by our system, asking for some more details for that reference number and fills in other fields based on that call.

Are either of these possible? All documentation on JSON importing seems to suggest saving it to a local file and important it but that seems a little clunky - would much rather have a REST call lookup if possible.

Thanks,

Barry

4 answers

2 votes
Barry Pollard May 31, 2016

Looks like option 1 is fairly easy as detailed here:

https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue

So something like this works:

curl -D- -H "Authorization: Basic ZnJlZDpmcmVk" -X POST -d @new_jira.json -H "Content-Type: application/json" "http://jira.laya.ie/rest/api/2/issue/"

Where new_jira.json file contains the following:

{
"fields": {
"project":
{
"key": "TEST"
},
"summary": "REST ye merry gentlemen.",
"description": "Creating of an issue using project keys and issue type names using the REST API",
"issuetype": {
"name": "Task"
}
}
}


Of course in the real world I wouldn't use Curl and so wouldn't need the file but this serves to prove this works.

Very nice and no need for any plugin or the like. I'm impressed.

Option 2 looks a bit more complicated so not sure if that's possible.

 

 

Barry Pollard March 29, 2019

BTW we did get option 2 working as well fair easily. As part of a workflow we call a webhock which calls a JSON endpoint at our system to let us know a Jira has been create or updated. Our system then calls jira back using the update APIs (https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#editing-an-issue-examples) and fills in the data it wants to send across.

 

So we are basically using Jira as a case management/workflow tool to supplement our CRM for specific use cases. It works very well and allows the flexibility of Jira (easy to add fields, change workflows, assign issues, audit history, permissions...etc.) and was significantly cheaper to implement than to extend the CRM with all this functionality (especially if we wanted to make it flexible).

A few points to note for anyone else considering this:

1) You obviously need the ability to process JSON messages and endpoints. If you have software developers to do this for you then this is a runner. Otherwise not so much.

2) You need to define a clear owner of the data as data duplicated in two systems will get out of sync as you can never 100% guaranteed messages will make it through and wont overwrite each other.  Some data will be owned by Jira, som by the other Systems. They should not be allowed to edit each other's data. A batch job to resync open cases nightly is something we're considering.

3) Jira is limited in screen layout. Grouping fields by tabs is a step  in right direction (though they are looking less and less like tabs with each Jira release!) but other layout is very limited and cannot remove certain fields, or show fields with null value...etc. All the top things people are asking for on Jira's bug list.

4) Dashboards are also limited. Plugins like SumUp help but limited layouts and no ability to filter multiple gadgets with date selectors or the like. We ended up pulling data out of Jira and our CRM into a properly BI tool. We looked at eazyBI but it overwhelmed us.

Overall, with those minor grumbles apart, it was a very positive experience and we added more users and departments to this with similar work. Jira is no longer a software project management tool but a general purpose work management tool. The APIs are very nice and allow ease of integration to other systems. Just fix those minor asks Atlassian and Jira can grow to be a much more powerful tool in organisations!

0 votes
Steven Breton van Groll May 28, 2019

@Jaydeep.Patel 

For our ITSM-tool (TOPdesk) it works with escape \J[variable]\j.

With your variable it should be:

"description": "\J${cf_defect_details_552}\j",

I do not know if your application is able to escape text with \J...\j.

@kaymoonwitch 

Does your request fail? If so, what is the error message?

kaymoonwitch May 28, 2019

@Steven Breton van Groll 

Well, I did end up figuring it out. 

Turns out it's not Jira; it's TOPdesk. Basically, the HTTP Request gets appended with a '?' messing up the entire setup. I have no idea how you got it working, unless we are indeed running very different versions. So I resorted to using https://jira.server/rest/api/2/issue as Server and using expand=names as 'Initial Line'.

TOPdesk just logs 'HTTP request Failed'. But I am now able to reach Jira, I believe. (I can't access the logs for it.) 

So even though I gave it my best, TOPdesk has me beaten it seems. 

Steven Breton van Groll May 28, 2019

@kaymoonwitch 

I used the old manner of creating JIRA issues also with the old TOPdesk-version.

With these config it should work:

TOPdesk-JIRA-httprequest.png

Body:

{
"fields":
{
"project": {"key": "[JIRA ProjectKey]"},
"summary": "[Korte_omschrijving_(Details)]",
"description": "\J[Verzoek]\j",
"reporter": {"name": "[JIRA-user with needed permissions]"},
"issuetype": {"name": "Bug"},
"customfield_10300": "[Incidentnummer]",
"customfield_15300": "[Aanmelder_(geregistreerd)]",
"customfield_15301": "\J[Actie_(alle)]\j"
}
}

Make sure that TOPdesk sends input for all the required fields of your JIRA-project. This depends on the config of your JIRA-project. You could check this at the create issue screen of your project in JIRA.

Port 443 from your TOPdesk-server to your JIRA-server has to be open.

Like kaymoonwitch likes this
kaymoonwitch May 28, 2019

Hey @Steven Breton van Groll ,

Thank you for still responding to me. I really do appreciate it. 

I have it configured exactly like that, but I've noticed that TOPdesk sends the following http request:

https://jiraserver?/rest/api/2/issue A question mark is inserted, which throws off the entire thing. Could be a bug in the ancient version we're running. 

0 votes
Steven Breton van Groll July 11, 2017

I'm busy developing option 1 to integrate our ITSM-tool with JIRA.

I'm able to create issues in JIRA, but only with string lined calls.

Now i'm stuck on the description field.

For example: if the description field in our ITSM-tool is filled with tons of information in several lines, the api-call will fail.

I am not able to parse that information to a string. The ITSM-tool doesn't have any solutions for this.

JIRA_description_field.jpg

As you can see, field description is a variable (verzoek) of our ITSM-tool. In the process of sending the information to JIRA field description will be filled in automatically with text of our ITSM-tool. Often this variable is filled with information on several lines.

Does anyone have a solution for this?

Jaydeep.Patel December 9, 2018

@Steven Breton van Groll : Did you got any solution for the issue of multiline description?

Steven Breton van Groll December 10, 2018

@Jaydeep.Patel: well in our ITSM-tool (TOPdesk) it is possible to use this escape \J<variable>\j.

With this escape TOPdesk is able to send text in multiline to JIRA.

Since release November 2017 TOPdesk has new functionality to connect with third applications like JIRA. It names "action sequences". With this functionality it is possible to execute several http-requests in sequence. Every request will be escaped automatically by TOPdesk, so text will be sent mutiline as well.

These requests has to be build in language Freemarker Syntax of Apache.

Jaydeep.Patel December 10, 2018

@Steven Breton van Groll : Thanks for heads up, Below is my json call for jira issue creation. Could you please update how exactly we can try with \J<variable>\J 

 

---

{
"fields": {
"project":
{
"key": "SUP"
},
"summary": "${cf_defect_description_551}",
"description": "${cf_defect_details_552}",
"customfield_10053": "${ticket_identifier}",
"issuetype": {
"name": "${cf_defect_type_553}"
},
"priority": {
"name": "${ticket_priority_code}"
},
"reporter": {
"name": "${assigned_to_firstname}.${assigned_to_lastname}"
},
}
}

---

kaymoonwitch May 27, 2019

I realize this is an old thread; and I do apologize. 

The company I work for is still using TOPdesk 5.4 SP1, which means we can't use the new API. 

I've configured an HTTP request; 

Server: jira.server.local Port 443

Initial Line: POST /rest/api/2/issue HTTP/1.1

Headers

Content-Type: application/json
Accept: application/json
Authorization: Basic <encoded credentials>

Message

{
"fields": {
"project":
{
"key": "MON"
},
"summary": "TEST [Incident_Number]",
"description": "Creating an issue via REST API and topdesk",
"issuetype": {
"name": "Bug"
},
"reporter": {
"name": "my name"
},
}
}

 It seems TOPdesk prepends http:// ; is there something in the Jira setup I am missing?

0 votes
Chris Dunne
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 31, 2016

I've been playing with Zapier lately (www.zapier.com). It provides an integration with JIRA to create issues.

Can your application make a call to a webhook? If so Zapier can intercept that call along with all the JSON data you send in the body of the request. Zapier can pass this data along to JIRA to create an issue.

I'll probably wirte up a blog article on this at some stage but you can get an idea of what I am talking about here.

I think at the very least this will enable you to test out your integration flow and usability.

The second option you mention is also possible but would require a plugin and that would not be so simple.

Let me know if I can help.

Chris

 

Matt Palermo June 15, 2018

That cert expired on getjirified.com...

 

Validity Period
Issued On Sunday, May 21, 2017 at 8:00:00 PM
Expires On Tuesday, May 22, 2018 at 7:59:59 PM

Suggest an answer

Log in or Sign up to answer