SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.






.NET Framework, ASP.NET

ASP.NET, Windows Forms, Controls, .NET Framework and Visual Studio Articles

ASP.NET Forums

Visual Studio Forums

.NET Development Blog

Certification Exams Blog




Jira Integration in VB.NET using REST API Methods to Search Jira Issues

In this .NET Framework tutorial, I want to show how Jira Integration can be done using REST API calls with HTTP WebRequest objects in a sample project. In short JIRA APIs are used to query Jira issues. Web service is called using HTPP GET method and JSON response of the API call will be fetched.
Using SQL Server 2017, programmers can use new JSON support features of SQL Server data platform to parse JSON response from the REST API calls.

What is JIRA software?

JIRA is a software used for project management and especially for issue tracking by project teams who prefer agile methods for managing project. Please visit to Atlassian for more official information about Jira software and its usage as a project management tool and its capabilities for integrating to other well-known software development tools.

I have been using JIRA as a tool for managing agile project sprints, issues and backlog items, etc within the agile project teams. HP Service Manager (HPSM) can be integrated with Jira using REST API provided for JIRA Server Platform.

This tutorial is created after an application is created to fetch Jira issue tracking data for defining and measuring KPI figures for agile teams working with JIRA tool.


JIRA REST API Methods to Query Issues for a Project

Atlassian provided a REST API for developers who are responsible for integrating Jira with other tools like HPSM, Bitbucket, Bamboo, etc. Developers can refer to JIRA REST API reference for complete list of API methods and how to use them.

VB.NET codes that I share in this tutorial shows how programmers can query JIRA issues for a specific project using SEARCH API method.

If you read the above Search API documentation, a jql parameter which is a JQL expression is passed to the API method via URL.
The JQL expressions can simply be formed and viewed at Seach page that can be launched by following SDD: Issuetracker > Issues > Search for Issues menu options.

open search for issues page to build jql query on JIRA

For example, using Search a JIRA user can build own custom JQL query (Jira Query Language) to filter required issues as a list.
As an exemple, following jql is build for listing jira issues of a specific project that are updated since the beginning of week.

search JIRA issues on SDD IssueTracking portal using JQL

On Search page, an SDD user can build the jql expression to search Jira issues. After the execution of the JQL search filter if you check the URL of the browser, you will be able to get the URL address that can be called via get method of the REST API Search method.

https://issuetracking.kodyaz-sdd.com/issues/?jql= project%20%3D%20%22ART%40S4%22%20AND%20 updatedDate%20%3E%3D%20startOfMonth()%20ORDER%20BY%20id%20ASC

Note for the programmer: updatedDate is not a valid parameter for the issue search method. Method returns all issues without checking the updated date value of the issues. The valid request parameters used for the JQL can be found in the API method documentation.

For this Jira integration tutorial using VB.NET, I will use following jql expression:
jql=project%20%3D%20%22ART%40S4%22%20&startAt=1&maxResults=5
Above is partly HTML encoded string for: jql=project="ARTS@S4"&startAt=1&maxResults=5
In your coding, you can build your URL simply by concatenating query parameters and their values. And then you convert it using HTML encode.
The project name of the Jira issues that are created under, for pagination starting from 1 with max results of 5 issues

Let's see how VB.NET code can be implemented to call SDD Rest API Search method using above JQL oarameter

First of all, .NET Framework developers require two namespaces System.Net for authorizations and System.IO for working with Search API JSON response
So add following "Imports" code lines at the beginning of your program

Imports System.Net
Imports System.IO

Following code block builds the URL that will be called for REST API Search method.
The JQL query is formed and attached to the tail of the API method URL.
Of course, developers can modify below code and turn it into a more generic and dynamic way according to their requirements.

' WEB API URL
Dim sURL As String
sURL = "https://issuetracking.kodyaz-sdd.com/rest/api/2/search?jql="
sURL &= "project%20%3D%20%22ART%40S4%22%20"
sURL &= "&startAt=1"
sURL &= "&maxResults=5"

Then we are ready to create the WebRequest object using the URL address formed in previous step.

' Create Web Request
Dim objWebRequest As WebRequest
objWebRequest = WebRequest.Create(sURL)

If the developer is running this code to call Search method behind an internet proxy, then below code will be required to authenticate at the proxy server.
Please note, all given information is some dummy data to make the code more understandable for the developer.

' Proxy Authentication
Dim user As String = "TR\\KODYAZ" ' Domain user
Dim password As String = "KodyazPwd" ' Domain password
Dim myProxy As New WebProxy("proxy.kodyaz.com:8080", True)
myProxy.Credentials = New NetworkCredential(user, password)
objWebRequest.Proxy = myProxy

SDD or JIRA portal requires basic authentication and the developer who is making the REST API Search method call.
Programmer can get this header information using for example, REST Console application on a Chrome browser.

' Basic Authentication on Remote Web Site
objWebRequest.Headers.Add("Authorization: Basic TXHhaHBlbi3ZaXytNXo5QWSeNjM7NKL=")

Programmer is now ready to send the request and get the response of the API call.
Following VB.NET code shows how the JSON response of the JIRA REST API call can be fetched using Stream object.

' Get Response
Dim objStream As Stream
Try
 objStream = objWebRequest.GetResponse.GetResponseStream()
Catch ex As Exception
 Console.Write(ex.ToString())
 Return
End Try

In the following code, top 5 JIRA issues are read using Search API and output response in JSON format is displayed on the console.

' Display API Query Results
Dim i As Integer = 0
Dim sLine As String = ""
Dim objStreamReader As New StreamReader(objStream)

Do While Not sLine Is Nothing
 i += 1
 sLine = objStreamReader.ReadLine
 If Not sLine Is Nothing Then
  Console.WriteLine("Line {0}: {1}", i, sLine)
 End If
Loop

Of course instead of writing the API response on the Console, the .NET developer can parse the JSON string using VB.NET code or pass the string value as an input paraneter to a SQL Server database procedure and parse the JSON string using SQL Server 2017 JSON support.
Please refer to SQL Server tutorial showing how to parse JSON string using OpenJSON on a sample web service response from AWS.

And for Microsoft .NET Framework developers, I have copied a screenshot of the codes I have developed for querying SDD Issue Tracking portal for JIRA issues list. As a programmer, the VB.NET code is not complex. The only thing to take care is choosing the correct JIRA REST API for solution of your requirements.

call REST API Search method to list JIRA issues

I hope this programming tutorial helps .NET developers who are working on JIRA integration projects by calling REST APIs published by Atlassian.










Copyright © 2004 - 2018 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems