Jira is Atlassian’s software for error tracking and project management. Users working with any APEX application often need to report an error regarding the application usage or data they work with. Instead of logging in to Jira, looking for a specified project, using a wizard that will allow to create a new request (name, type, description, request assignment, etc.), the user can easily use the a solution implemented fully in Oracle Apex, which we will introduce step by step in a new Oracle APEX article series – Let’s integrate with Jira! In the examples below we will use the Oracle Database 12c Enterprise Edition database and the Oracle SQL Developer Version 18.2. tool.
This is the third and last article in the series. In the first article, we learned what OAuth authorization is and how the token exchange process works. In the second entry we used Java in the Oracle database to implement the digital signature using the SHA1-RSA encryption algorithm. Now it’s time learn how to create your first request in Jira from an Apex application. And this will be the goal of this article.
Jira provides a REST API that allows integration of Jira with other applications. Thanks to the API, you can create, update, modify and delete data in Jira using standard HTTP methods such as GET, PUT, POST and DELETE.
We will use a POST HTTP request to create a Jira request. In the headers we will pass parameters such as the format and length of the sent message (Content-Type and Content-Length). However, the content of the Authorization header will be created according to the rules described in previous articles, example:
v_req := utl_http.begin_request ('http://localhost:8081/rest/api/latest/issue', 'POST', 'HTTP/1.1');
oauth_consumer_key="key value in the Jira configuration",
oauth_nonce="unique string for the request",
oauth_signature="signature generated using the SHA1RSA method"
oauth_signature_method="the method of signature used",
oauth_timestamp="number of seconds since January 1, 1970",
oauth_token="Access Token returned in the third step of OAuth dance",
oauth_verifier="Verifier returned after approving user authorization"
utl_http.set_header(v_req, 'Content-Type', 'application/json;charset=UTF-8');
utl_http.set_header(v_req, 'Content-Length', length(v_content));
The content of the request will be saved in JSON format. According to the example below, a new high priority bug report will be added to the TPFAU project:
v_content := '
"summary": "Example Summary",
"description": "Example Description",
Creating the Oracle Application Express form
In a series of articles, we described the so-called ‘OAuth Dance’ in detail, creating a signature using Java, and provided examples of using the Jira REST API. Based on all this information, in a few steps we can create a form in the Oracle APEX application that will allow us to create a request in Jira.
Business use case
We will use a specific business case for the solution presented. The user analyzes the report of the results of scientific experiments. During the analysis, he notices that the results are significantly different from the norm, which may be due to incorrect data. The user wants to create a bug request in Jira. The request should have the appropriate title, description, high priority and should be assigned to the person indicated by the user.
- We create a link column with the Jira icon on the experiment report.
- We create the process for sending a request to generate a Request Token. In the request header, we define the address of the Oracle APEX form to create a ticket in Jira. Then, add the returned Request Token to the Authorization URL and define the redirection to the URL just created. The process should start after pressing the Jira icon.
- After confirming the identity on the authorization screen, the user will be redirected to the address defined in the request header from point 2.
- Next, we create a ‘Before Header’ process that retrieves the authorized Token and Verifier Request values from the URL using the owa.num_cgi_vars library and writes their values to APEX items.
- We create another ‘Before Header’ process that will send a request to generate an Access Token and save it to the APEX item.
- We create a form that allows you create a request in Jira with all attributes described in the business case.
- We add a process sending a request to create a bug in Jira using the API described in the first part of this article.
In a series of articles we have described the integration of the Oracle APEX application with the Jira tool. In the first article we presented in detail the operation of the “OAuth Dance” process which is based on the exchange of tokens. In the next entry we described the signature creation using Java. The last, third article contains an example of using the Jira API and is a summary of a whole series of entries showing how to create an Oracle APEX form to create a new Jira request for a specific business case.