Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JIRA Rest API - Get all projects filtered by {Creator, Reporter, Assignee, Watcher)

Chad S. May 27, 2015

I would like to send a request to get a list of projects but filtered.

So right now I am using the http request like so:

https://myserver/rest/greenhopper/1.0/rapidviews/list.json

This gives me back a list of all the projects on the agile board but I want to only get the projects filtered by username that i have available so a filter that would be like creator = username or reporter = username or assignee = username.

If i cannot do it this way can I get a confirmation of that and what would be the way to get this kind of information? I am looking to slim down the rest api calls that i make (and the time it takes to generate all the data that I need. Currently we have 120 projects so i really only want to deal with projects that the user relates to somehow (by the filters).

 

Any help/feedback/suggestions would be appreciated.

 

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 29, 2015

Hi, Chad.

As you want to search by projects in which the user has reporter or assigned anything, you'll need to use the REST endpoint to run a JQL query: https://docs.atlassian.com/jira/REST/latest/#d2e2301. And then filter the output by the projects.

For example,  if you are running through the terminal, you can see what projects they have issues assigned or reported using:

curl -ss -u matheus:matheus "http://quicksilver:8080/jira/rest/api/2/search?jql=assignee=matheus%20OR%20reporter=matheus%20OR%20creator=matheus&fields=project&maxResults=10000" | python -m json.tool | grep project -A 3 | grep key | sort | uniq
                    "key": "AGILE",
                    "key": "BILE",
                    "key": "MAT",
                    "key": "MP",
                    "key": "MSD",
                    "key": "TST",
                    "key": "TT",
                    "key": "TTP",

I hope this helps!

Chad S. May 29, 2015

Yes that helps thanks! The only problem that I have with this is that while i see projects in the JSON data there doesnt seem to be any parameters that give me any indication about the sprint information. With the query that I mentioned in my initial question, from that query i can get the jira agile board id and then use that to form a query to get the sprint information, (is sprint active or future). Is there any way to derive that information from the jql statement that you have provided???

Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 29, 2015

Oh yeah, if you run only: curl -ss -u matheus:matheus "http://quicksilver:8080/jira/rest/api/2/search?jql=assignee=matheus%20OR%20reporter=matheus%20OR%20creator=matheus&fields=project&maxResults=10000"; | python -m json.tool You'll see a lot more info :P You can get all IDs instead of the keys with: curl -ss -u matheus:matheus "http://quicksilver:8080/jira/rest/api/2/search?jql=assignee=matheus%20OR%20reporter=matheus%20OR%20creator=matheus&fields=project&maxResults=10000"; | python -m json.tool | grep -A8 "\"project\"" | grep "\"id" | sort | uniq | awk -F\" '{print $(NF-1)}' And then pass along to the other rest :)

Chad S. May 29, 2015

Well to give you a little context, I am running all these requests in Objective-C code so i am making these http requests in code dynamically. The project Ids that you get dont seem to correspond to agile jira board ids that would use to get sprint information (whether this project has an active sprint or a future sprint - or any sprint available at all) if you were to run my greenhopper http request above (replacing server with whatever) you should get a list of projects with an "id" parameter. This should be the first parameter for each project. This is different than the id under the "filter" dictionary. This "id" corresponds to the specific agile board id that you use to get any sprint information.

Chad S. May 29, 2015

I hope that makes more sense as to what I was looking for...

TAGS
AUG Leaders

Atlassian Community Events