5

In the overview of the Jira Rest Java Client, Atlassian specify:

The Jira REST Java Client works with Jira Server, but not with Jira Cloud.

Is there a client library for the REST APIs of Jira cloud?


I can't find any open source libraries on the internet that are geared specifically towards using the Jira cloud REST APIs.

The following question seems to be implicitly asking the same thing as I am, but is explicitly focused on the existence of a POM: How to use JIRA REST client library?. So the answer there focuses on advise on usage of a POM found on Maven.

Colm Bhandal
  • 3,343
  • 2
  • 18
  • 29
  • We started using the library that, according to the comment above, does not work with Jira Cloud. And it works. So I guess that's just Atlassian covering themselves when in fact the code probably works, at least most of the time. – Colm Bhandal Mar 06 '20 at 16:58

2 Answers2

5

I'm not aware of an open source client library for Jira Cloud (written in Java) and also a quick internet search does not provide any good results. But you can generate your own client since Atlassian is providing a Swagger/OpenAPI definition for their cloud REST API:

How to download the OpenAPI/Swagger definition for Jira Cloud's REST API

Then you can generate your own client using e.g. Swagger Codegen or OpenAPI Generator into your preferred language of choice. I quickly tried it out by myself using the OpenAPI Generator but it failed because of an error in the Swagger definition - if you're interested, you could try to fix it by yourself or report it in the Atlassian Developer Community.

About the Jira Rest Java Client

You can probably use the client for most of the Jira Cloud REST API endpoints as they are similar to Jira Server. However, keep in mind that there are a few smaller differences between Jira Cloud REST API and Jira Server REST API. For example, there are endpoints which only exist in Jira Cloud like Jira Expressions. Or endpoints which are deprecated and will be removed soon because they now require pagination request parameters, like filtering for projects. Also, the client does not support JWT authentication or OAuth but only Basic Authentication - but this may not be necessary in your situation, depends on your use case.

s.hesse
  • 1,900
  • 10
  • 13
  • Thank you s. hesse. A thorough answer. I was not aware of the ability to autogenerate the client lib from the REST API, though it does make perfect sense such automation exists, in general, now that I think of it. As for the server lib, I think for our use case it will suffice. Since JRJC is open source, our plan is to use it as a JAR until something breaks, and if that happens, then download the source and tweak it to work with the cloud wherever we need. Thanks for the heads up though – Colm Bhandal Mar 08 '20 at 18:34
3

Client library

An associate developer has finally built this library:

https://gitlab.com/hectorjsmith/jira-api-client

There's a README on that site for how to use it. It builds upon the raw library - see below.

Raw Library Using OpenAPI

Thanks to s. hesse for pointing me in the right direction, I got a Kotlin library generated using the Open API tools. The Open API generator was a bit buggy, first complaining about the JSON provided by Jira and then creating Kotlin with a little bug in it. But with some tweaking the Kotlin compiled to a JAR. I haven't tested yet but here's the repo for anybody interested: https://github.com/ColmBhandal/KotlinJiraCloudClient.

Notes

The library that's autogenerated by the Open API Generator is pretty ugly. That's to be expected of auto-generated code from a tool that's not specifically tailored towards Kotlin. However, there's not much point prettifying it as the APIs may change and so regenerating this might be necessary. Instead, it's advisable to generate another layer of code between this ugly library and your client code. The code would be a sort of decoration/facade on top of the raw exposed code that's auto-generated, wrapping it to give type-safety and better ease of use.

Python Alternative

It also looks like there's a Python library out there for connecting to Jira, though we didn't want to use Python in this case: https://pypi.org/project/jira-cloud-python/

Colm Bhandal
  • 3,343
  • 2
  • 18
  • 29