You can translate the document:

Introduction

In this document, we will explore the integration of Jira Software in the Denodo Platform and learn how to use all the possibilities the Jira REST API has.

Overview

Jira connection with  OAuth 2.0 Authentication

In this section we will see how to enable OAuth 2.0 authentication in Jira so we can use this authentication later when connecting from Denodo. Other authentication methods are available.

  1. From any page on Atlassian Developer, select your profile icon (top-right corner) and select “Developer Console” or follow the link to the Developer console.
  2. Click on “Create” and, from the dropdown, select “OAuth 2.0 Integration”. Select any name you want for the app.
  3. Select “Permissions” in the left menu and add the Jira API scopes you will need. You can check the scopes required by different actions in the left menu of The Jira Cloud platform REST API (as you can see in the following screenshot).

In our example, we are going to use all the classic scopes of the “Jira Platform REST API”.

  1. Go to the “Authorization” tab of the menu, click on the “OAuth 2.0 (3LO)” “Configure” button and specify the “Callback URL” (also known as “Redirect URI”), the default value for Denodo is http://<host>:<port>/oauth/2.0/redirectURL.jsp.

  1. Finally, in the “Settings” tab you have to copy the “Client ID” and your “Secret” to use later.

Accessing Jira’s REST API from Denodo

  1. To access Jira’s API we will create a new JSON data source:
  1. From the VDP admin tool go to File > New > Data source > JSON.
  2. From the Web Design Studio, you can hover over the connected virtual database, and click on the three dots to go to New > Data Source > JSON.
  1. For the “Data Route”, select “HTTP Client”.
  2. In the “Authentication” section:
  1. Choose the “OAuth 2.0” type of authentication.
  2. Paste the “Client ID” and the “Secret” of your created app (explained above).
  3. Click “Launch the OAuth 2.0 credentials wizard to help you to obtain these credentials”.

  1. Fill all the boxes:
  1. Token endpoint URL: https://auth.atlassian.com/oauth/token
  2. Authorization server URL: https://auth.atlassian.com/authorize
  3. The “Redirect URI” has to be filled with the same “Callback URL” that was entered in the Jira configuration.
  4. The “Scopes” boxes have to be filled with the codes of the scopes that you have selected in Jira’s developer console (if a refresh token is required, it is necessary to add the code “offline_access” as another scope).

  1. Go to the next section, click on “Generate the authorization URL” and give access to the Denodo server to your Atlassian account.
  2. Once you have accepted, you will be redirected to a link where you must copy the URL that appears and paste in wizard’s step 3.
  3. In the last wizard’s step, click on “Oauth 2.0 credentials” and copy the credentials to the clipboard. Then, close the window clicking “Ok”.

  1. Finally, if the “offline_access” code was included as a scope, you have to include an extra parameter of the refresh token request where the name has to be “grant_type” and the value “refresh_token”.

  1. In the “Configuration” section:
  1. Select a default HTTP method (it has no impact, as when creating base views, you can select it again), in this example we will select the GET method.
  2. Write the “Base URL”, which for Jira apps follows this structure:

https://api.atlassian.com/ex/jira/{cloudid}/{api}

Where {cloudid} is the id for your site. To get this id, we have to use this url in our browser:
https://{my-site-name}.atlassian.net/_edge/tenant_info

Replace {my-site-name} with your Jira’s site name.

The {api} field has to be replaced with rest/api/2. Finally the “Base URL” will be something like like:

https://api.atlassian.com/ex/jira/624*****-2***-4***-9***-0a85********/rest/api/2

  1. Save the data source.

Creating Base Views

Depending on the selected scopes, we will be allowed to use different endpoints from the REST API to perform different actions. In this section we will see some examples on how to integrate some common features available in the REST API.

To integrate the API we just need to use a single data source as explained in the previous section. On top of this data source we will create as many Base Views as needed for the different operations that we want to perform..

Now, we can create base views to get information from Jira or to add any Jira data from Denodo.

Base views using the GET HTTP method

To obtain data from Jira, we can create different types of base views using the GET HTTP method.

In the following example, we are going to create a base view for retrieving specific issue details by specifying the issue’s ID. The relative URL for carrying out this action is /issue/{issueIdOrKey}, being {issueIdOrKey} the value to provide a specific issue’s ID (in our case, we use an interpolation variable by substituting {issueIdOrKey} with @ISSUE_ID). The work scheme for this type of actions is as follows:

  1. Open the data source and click on “Create Base View”.
  2. Enter a “Relative URL”, depending on what action you want to carry out (you can consult the URLs required by different actions in The Jira Cloud platform REST API).

When something in a Jira URL is inside {}, it means that is a value we have to enter.

  1. Make a “Test Connection” and if it works, finish creating the base view.

  1. You can create a flatten view to be able to see the results more easily. I did it to receive the following simple result:

Other relevant actions you can make with the GET method are for example:

  • Obtain a list of all the issues (without many details) and search in it by keywords, including a query parameter such as ?query={queryString} to return a reduced list of issues matching that query string.

        

  • Obtain a list of all the issues (as detailed as if you search by ID) and make advanced queries using JQL (Jira Query Language), including the query parameter ?jql={jqlExpression} (to learn more about JQL visit Tutorials for Advanced Search in Jira | Atlassian).

        

Base views using the POST HTTP method

To use some REST API endpoints that create or update data in Jira we will need to use a POST http request.

In the upcoming example, we are going to create a base view for creating issues or subtasks from a JSON-based structure that will be introduced in the post body, containing the information needed to create the new Jira issue. The relative URL for carrying out this action is /issue. From Denodo the procedure will be very similar to the previous one:

  1. Open the data source and click on “Create Base View”.
  2. Input the “Relative URL” of the action you want to carry out. When you select the POST method, you will have to enter a “Post Body” indicating the information that you want to send to Jira.

The post body has to have a JSON structure with the fields indicated by the Jira documentation. For the example we have use the next basic structure:

\{

    "fields": \{

       "project":

       \{

          "key": "@PROJECT_KEY"

          \},

       "summary": "@SUMMARY",

       "description": "@DESCRIPTION",

       "issuetype": \{

          "name": "@NAME_ISSUETYPE"

       \}

   \}

\}

We use  “\{“ and “\}” instead of using “{“ and “}” as they are reserved characters and we need to escape them.

  1. Click on “Test Connection” and, if it works, create the base view.

  1. Now we can create issues in our Jira’s project by executing the base view introducing values to the arguments we established.

References

The Jira Cloud platform REST API

OAuth 2.0 (3LO) apps

What is advanced search in Jira Cloud

Questions

Ask a question

You must sign in to ask a question. If you do not have an account, you can register here