News Archive
PhpRiot Newsletter
Your Email Address:

More information

Using JIRA's REST API to Create a Dashboard

Note: This article was originally published at Planet PHP on 26 March 2012.
Planet PHP

If you read this blog often, you'll know that I am:

  • crazy about APIs
  • living with some accessibility issues

Put these two things together and what do you get? Actually don't answer that! Today what you get is an example of integrating with JIRA's REST API, because their recent "upgrade" locked me out of the issue listings pages completely and I really do need to be able to see a list of bugs! Their bug editing screen is quite usable, so it's just the list that I need here, but you could easily call their other API methods as you need to.

These examples are PHP and use the PECL_HTTP extension, because it's awesome, but these examples could be easily adapted to use another language or library.

What's The REST URL?

We have hosted JIRA from Atlassian, which I think is now called Jira Studio, because they give free pretty-much-unlimited licenses to open source projects, and for that I don't think I'll ever be able to thank them enough. Not enough organisations recognise the value of open source!

Our "normal" JIRA URL:

The URL to access the RESTful service: Note this requires SSL.

Getting a List of Issues

This should be easy, but many services make it hard. Not this one, here's my code:

$request = new HttpRequest(); $request-setUrl(''); $request-send(); A $issue_list = json_decode($request-getResponseBody());

Now I have all the issues in $issue_list - this is paginated, you can control how many issues you get in a list; the default is 50 I think. You can also pass in any search query - basically the same as the search options that you see in JIRA itself. This uses a language called JQL, and you can find some JQL documents here.

I added some parameters to only show me open and reopened issues, so my code sample now looks like this:

$request = new HttpRequest(); $request-setUrl(''); $params = array("jql" = "status in (open, reopened)"); $request-setQueryData($params); $request

Truncated by Planet PHP, read more at the original (another 8250 bytes)