Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I limit the fields or the number returned for rest/api/latest/project ?

samfullman April 16, 2022

I am trying to add `?fields=key,id` or `?limit=50` but the output seems unchanged.  Can the projects list query output be leaned out or changed?  Thanks

2 answers

1 accepted

1 vote
Answer accepted
Oliver Siebenmarck _Polymetis Apps_
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.
April 16, 2022

Hi @samfullman ,

Just to add to @Bill Sheboy's answer: The endpoint /rest/api/2/project is marked as deprecated in both Version 2 (current) as well as Version 3 (beta) of the Jira Cloud REST API.

If you want to be on the safe side for the future, you should use /rest/api/2/project/search (Get Projects paginated), which a) uses maxResults and b) is limited by default. It also supports expansion meaning, you can choose which attributes of a project to expand on. 

Finally, if you really want to limit not the amount of projects returned, but rather limit which attributes are returned: That's not as easily done, but I would suggest looking into Jira Expressions. While they are geared towards issues instead of projects, you can dynamically  load projects into the evaluation context using the new () syntax. Once you have done that, you should be able to select whatever attributes you want and return them.

Hope that helps,
 Oliver

samfullman April 17, 2022

Hey Oliver, this is a concise answer. 

A thought, unlike tickets, projects have a more or less finite limit (though my company shows 680 of them!) - it would be nice to call /rest/api/[2|latest]/project/search and just get everything - if that's possible

Oliver Siebenmarck _Polymetis Apps_
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.
April 17, 2022

Hi @samfullman ,

I don't believe there's an out-of-the-box option, apart from the deprecated API call. 

However, if you are not afraid of a little Javascript, you can use Atlassian's Forge platform to build your own custom REST endpoint to deliver exactly what you need. The way to do this would be with a so-called webtrigger module.

Even if that isn't for your company, it's always a good idea to learn Forge as Jira admin, even if you do not want to build your own apps. You can just as well use it to customize Jira cloud in ways that so far were only possible with scripting apps. They have a one-day virtual conference coming up about this, too. 

Like Bill Sheboy likes this
0 votes
Bill Sheboy
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.
April 16, 2022

Hi @samfullman 

Please try maxResults as described here on the REST API information for Jira Cloud:

https://docs.atlassian.com/software/jira/docs/api/REST/1000.824.0/

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events