Obtaining a list of Components in a Project (version 7)

Bill Blinn June 20, 2017

The company I work for is upgrading JIRA to v7.3.6 from v6.3.12 and I'm having trouble finding answers to some questions. I am just a user, not an administrator. Here is one of the questions:

Currently I can obtain a list of components in a project and their process ID numbers by using this API call:
https://JIRA-URL/rest/api/2/issue/createmeta?projectKeys=DSCUST&expand=projects.issuetypes.fields&issuetypeName=Story

However, when I replace the version 6 JIRA-URL with the one for version 7, I get an empty json set: {"expand":"projects","projects":[]}

Research suggested that https://JIRA-URL/rest/api/2/issue/createmeta?findAllForProject(DSCUST) would provide what I needed. Although I get a long block of json code, Components that exist in the project are not listed.

The Project (DSCUST) exists and some Components have been defined.

Could someone who knows more about this than I do (and that will be just about anybody) toss me a clue?

2 answers

1 accepted

4 votes
Answer accepted
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 20, 2017

It's easy and possible using REST APIs to get the list of project components.

Latest release -- https://docs.atlassian.com/jira/REST/server/#api/2/project-getProjectComponents

REST end point - GET /rest/api/2/project/{projectIdOrKey}/components

 

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 20, 2017
Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 20, 2017

and yes it's supported by JIRA 7.x versions

Bill Blinn June 20, 2017

Thanks again, Tarun. I now have the needed information.

Tarun Sapra
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 20, 2017

Hello Bill, If you are satisfied with the answers, could you please accept them. Thanks.

0 votes
Balvant Gmail October 10, 2018

Please use below script and replace jira URL and login details, which will generate CSV file with all projects and corresponding Components, I already used for our Jira

import csv
import jira.client

from jira.client import JIRA

options = {'server': 'http://jiratest'}

jira = JIRA(options, basic_auth=('user-id', 'password'))

projects = jira.projects()

all_components = {}

for v in projects:
all_components[v.name] = ', '.join(map(lambda x: x.name, jira.project_components(v)))

with open('output.csv','w') as myfile:
writer = csv.writer(myfile)
for key, value in all_components.items():
writer.writerow([str(key),str(value)])

 

 

Pokala Venkatesh October 16, 2018

Hi,

   I am not able to get the results.....

 

ERROR:::

 

File "/home/vvdn/.local/lib/python2.7/site-packages/jira/client.py", line 472, in __init__
   si = self.server_info()
 File "/home/vvdn/.local/lib/python2.7/site-packages/jira/client.py", line 2133, in server_info
   j = self._get_json('serverInfo')
 File "/home/vvdn/.local/lib/python2.7/site-packages/jira/client.py", line 2549, in _get_json
   r = self._session.get(url, params=params)
 File "/home/vvdn/.local/lib/python2.7/site-packages/jira/resilientsession.py", line 151, in get
   return self.__verb('GET', url, **kwargs)
 File "/home/vvdn/.local/lib/python2.7/site-packages/jira/resilientsession.py", line 125, in __verb
   response = method(url, timeout=self.timeout, **kwargs)
 File "/home/vvdn/.local/lib/python2.7/site-packages/requests/sessions.py", line 525, in get
   return self.request('GET', url, **kwargs)
 File "/home/vvdn/.local/lib/python2.7/site-packages/requests/sessions.py", line 512, in request
   resp = self.send(prep, **send_kwargs)
 File "/home/vvdn/.local/lib/python2.7/site-packages/requests/sessions.py", line 622, in send
   r = adapter.send(request, **kwargs)
 File "/home/vvdn/.local/lib/python2.7/site-packages/requests/adapters.py", line 412, in send
   self.cert_verify(conn, request.url, verify, cert)
 File "/home/vvdn/.local/lib/python2.7/site-packages/requests/adapters.py", line 227, in cert_verify
   "invalid path: {0}".format(cert_loc))
IOError: Could not find a suitable TLS CA certificate bundle, invalid path: False

Balvant Biradar October 16, 2018

I used for test Jira and no ssl and also my Pyhton environment is 3.5 version and jira version 7.4.0

FYI, more on Jira and Pyhton interactions 

https://jira.readthedocs.io/en/master/api.html

Suggest an answer

Log in or Sign up to answer