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

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

Accepted Answer
1 vote
Tarun Sapra Community Champion Jun 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 Champion Jun 20, 2017

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

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

Tarun Sapra Community Champion Jun 20, 2017

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

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)])

 

 

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

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
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

26,389 views 2 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you