It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to Parse /rest/api/2/project GET results for "Name" comma "Key"?

Chris Annal Jun 05, 2017

I know this is simple for some, but I've searched the Atlassian JIRA forums and other REST API sites and still can't find a simple example of parsing the results of the GET command  for /rest/api/2/project.

In the example from https://developer.atlassian.com/static/rest/jira/6.1.html#d2e2990, the results are:

"self": "http://www.example.com/jira/rest/api/2/project/EX",
        "id": "10000",
        "key": "EX",
        "name": "Example",
        "avatarUrls": {
            "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
            "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
            "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
            "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"

Is there a simple command for having the results only include the following:

"EX, Example"  - this would be ONLY the key value and the project name, separated by a comma. That's ALL I want. Please don't respond if your answer is "I have a plug-in you can buy for this". I'm not the sharpest pencil in the box, but there must be a command that will get the desired data, without all the html garbage. 

Thanks

2 answers

1 accepted

0 votes
Answer accepted
chander inguva Jun 05, 2017

Hey Chris,

Hope this helps, I could get by Python Requests.

import requests
import json
headers = {
}


r=requests.get('https://jira.atlassian.com/rest/api/2/project', headers=headers)
k= json.loads(r.text)
searchresults = len(k)
for index in range(searchresults):
        print('Project Key is',k[index]['key'],'and project name is:',k[index]['name'])

Screen Shot 2017-06-05 at 1.51.15 PM.png

 

Cheers

Chander

Chris Annal Jun 06, 2017

Thanks, Chander!! This looks like what I need.

chander inguva Jun 06, 2017

Glad, that i could help you. 

Thank you please roaiting intent html

  1. Thankyou please for now html.glad 

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

7,133 views 22 35
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you