How to get list of project Key for Jira project

Ipsita Dash March 1, 2018

Hi,

I have more than 2000 projects in jira.

How to get the project keys for all the project by using a Rest Api?

 

Thanks,

Ipsita Dash

2 answers

1 vote
Fayaz Abdul July 20, 2020

Hello @Steve Thornhill @Ipsita Dash 

Here we are getting all the data but i just need project keys or project names, how do we get it?

Yoav Ashkenazi April 19, 2021

This worked for me:

curl -D- -u user:password -H "Content-Type:application/json" -X GET -k https://your-jira/rest/api/2/project 2>/dev/null | egrep -o 'key":"([A-Z]+)"' | cut -f 2 -d: | xargs
Roberto Cornacchia May 15, 2021

Even better, use proper json parsing on the output:

 

curl -s -u user:password -H "Content-Type:application/json" -X GET -k https://your-jira/rest/api/2/project 2>/dev/null | jq -r '.[].key'
Like Yoav Ashkenazi likes this
1 vote
Steve Thornhill
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2018

This code snippet will point you in the right direction

curl --user email@example.com:<api_token> \
  --header 'Accept: application/json' \
  --url 'https://your-domain.atlassian.net/rest/api/2/project'

All the calls are documented here - https://developer.atlassian.com/cloud/jira/platform/rest/?_ga=2.220028510.635558710.1519632796-1676897954.1510753882#api-api-2-project-get

Ipsita Dash March 1, 2018

Hi Steve,

 

Thanks for your reply. Upon running the curl command i am facing an error saying " api_token: No such file or directory" .

How does the above command worked for you.

 

Thanks,

Ipsita Dash

Steve Thornhill
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 1, 2018

If I am running it on a local server I use the following

curl --user steve --header 'Accept: application/json' --url 'http://localhost:8080/rest/api/2/project'

 

Substite the user and the url for your own ones.

Like Michael Schröder likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events