Extract data from JIRA REST API

i want to extract data from JIRA and eventually write it into an Excel file. for the extraction of data in the JIRA REST API i am using tREST and tExtractJSONFields. however the first component i use is tREST and NOT (tRESTClient), i use a REST API from JIRA and it runs without an error but only retrieves one single row...
see screenshot for my Job, in the first place i would like to retrieve all data from the REST API that i get from JIRA and later on filter for specific atributes.


NB. also i would like to add that when i use just tREST --> tLogRow, i only get the first part of the REST API JSON code... i don't get the whole REST API from JIRA. when i paste the url in the browser i do see the entire code...does anoyone know what i am doing wrong?
the URL in tREST = "..nl/rest/api/latest/search"
and the HTTP headers are: 


name: "jql" 

value: "issues=san-145


so the complete URL in the browser would be: ..nl/rest/api/latest/search?jql=issue%3Dsan-145




7 REPLIES
Community Manager

Re: Extract data from JIRA REST API

Hi 
It is better to use the special component tJiraInput which is available since version 6.2.1.
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: Extract data from JIRA REST API

Hi Shong,
thanks for the advice, this sounds much better to me as i just want to read data from JIRA.
i installed the new version and java8 on my machine, i started making a new job and when i want to use the tJIRAInput component i get the warning that i have to install at least one jar file.
when i select one OR all of them to download and install i get the following error message, can someone help me? please keep in mind that i am new to Talend and also don't have much experience with java too.
An error occured (Download slf4j-log4j12-1.7.2.jar failed!).
See log for more details.
java.lang.Exception: Download slf4j-log4j12-1.7.2.jar failed!
at org.talend.librariesmanager.utils.DownloadModuleRunnable.downLoad(DownloadModuleRunnable.java:117)
at org.talend.librariesmanager.utils.DownloadModuleRunnable.run(DownloadModuleRunnable.java:68)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Thanks in advance.

Re: Extract data from JIRA REST API

i think there might be a bug there, because i could not download and install the modules for tJIRAInput, i kept getting errors.
so i tried to insert the tJIRAOutput component, that one also needed modules to be installed (maybe the same modules) and via that component (tJIRAOutput) i was able to download and install them...so that did actually resolve the problem.
now the job runs smoothly and i get my API information in a tLogRow, so great that works!
can i now use the tExtractJSONFields or should i directly use the tFileInputJSON?
Community Manager

Re: Extract data from JIRA REST API

Hi 
The tJiraInput returns a json string, so you still need to use tExtractJsonFields to extract data from the return string. 
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

Re: Extract data from JIRA REST API

thank you for your response Shong, i am now trying to use tExtractJsonFields but i don't know what to fill in @ Loop Jsonpath query, see screenshot.
also the Json query is not clear to me, i now have there in the Column: id and in the Json query "$.issues"
but this does not return any rows. what kind of query commands can i use to retrieve such data. i wil post a part of the API here so you can see how it looks like.

{
"expand": "names,schema",
"startAt": 0,
"maxResults": 50,
"total": 1,
"issues": .l/rest/api/latest/issue/174784",
        "key": "SAN-145",
        "fields": {
           "issuetype": {
              "self": "https://jira..nl/rest/api/2/issuetype/7",
              "id": "7",
              "description": "Created by JIRA Software - do not edit or delete. Issue type for a user story.",
              "iconUrl": "https://jira..nl/secure/viewavatar?size=xsmall&avatarId=11615&avatarType=issuetype",
              "name": "Story",
              "subtask": false,
              "avatarId": 11615
},

Re: Extract data from JIRA REST API

i got this working now, i found out that i was still using the API directly from the browser instead of the API i get returned from the tJIRAInput component. for the same issue in JIRA i get slightly different API returned in JSON...
however, i now get data from the tJIRAInput thru tExtractJSONFields to tFileOutputExcel, but i only get data from the root..so if my JSON looks like this:
{
"expand": "operations,versionedRepresentations,editmeta,changelog,transitions,renderedFields",
"id": "174784",
"self": "https://jira..nl/rest/api/2/issue/174784",
"key": "SAN-145",
"fields": {
       "issuetype": {
             "self": "https://jira..nl/rest/api/2/issuetype/7",
             "id": "7",
             "description": "Created by JIRA Software - do not edit or delete. Issue type for a user story.",
             "iconUrl": "https://jira..nl/secure/viewavatar?size=xsmall&avatarId=11615&avatarType=issuetype",
             "name": "Story",
             "subtask": false,
             "avatarId": 11615
NOTE: this is just the top part of the JSON
i would like to retrieve data from the 'issuetype' asswell, does anyone know what JSON query i have to use to get to the nested data?
for attributes like  'id' or 'self' i just use the JSON query: "id" and "self" because i use the Loop Jsonpath query: "$", which should give me acces to all the data in the API right?

Re: Extract data from JIRA REST API

i also fixed that, i have the following json query that retrieves nested data: "fields.issuetype.name" so that is solved.
now i wan't to know if i can get API for a sprint rather than an project or issue?
because the tJIRAInput component only has two options (JIRA resource), ISSUE or PROJECT. but i also would like to have data on SPRINT level....
does anyone know how to manage this?