Jira API Get projects paginated

kamil gronert October 26, 2018

Hi,

 

I've found a method in documentation 

GET /rest/api/2/project/search

that returns all projects with some fields like 

"maxResults": 2,
"startAt": 0,
"total": 7

that can help me with pagination inside my mobile app.

But whenever i try to get a list of my projects i got response like this

{
"errorMessages": ["No project could be found with key 'search'."],
"errors": {}
}

 

It seems to me like jira api misleads 

GET /rest/api/2/project/search

with

GET /rest/api/2/project/{projectIdOrKey}

and it expects project key instead of /'search'

 

Is there any explanation to this?

 

Regards,

Kamil

 

2 answers

1 accepted

0 votes
Answer accepted
kamil gronert October 30, 2018

Currently i use 

GET /rest/api/2/project 

for fetching list of projects assigned to current user, but i noticed that this method is deprecated and documentation suggest to use 


GET /rest/api/2/project/search

Could you give me example of url for fetching projects list using JQL? I cannot find it, all it refer is JQL queries for getting issues from specified project

Santwana Sarangi {Appfire}
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.
November 3, 2018

Hi @kamil gronert,

Are you trying to use rest api for jira cloud or server? There are some APIs which are not available for the jira server, but available in jira cloud.

For example, this GET /rest/api/2/project/search api is available for the jira cloud, not the server. For jira cloud, it lists all the projects visible to the currently logged in user with pagination.

For jira server, the above rest call is treating as /rest/api/2/project/{ProjectKey}. That's why you are getting the error

{
"errorMessages": ["No project could be found with key 'search'."],
"errors": {}
}

To fetch all the projects visible to currently logged in user in the jira server, please use below rest call GET /rest/api/2/project. Unfortunately, with this rest call, you have to use your own pagination logic.

Hope this helps!

Thanks,

Santwana

kamil gronert November 8, 2018

Thank you for your reply, now i understand everything :)

Cheers :)

0 votes
Santwana Sarangi {Appfire}
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.
October 29, 2018

Hi Kamil,

/rest/api/2/project/search api searches for issues using JQL. You have to give query parameter for this rest call like this /rest/api/2/search?jql&startAt&maxResults&validateQuery&fields&expand.

As you have not given any query parameter, jira is taking the  "/rest/api/2/project/search" api similar to /rest/api/2/project/{projectIdOrKey}.

For detailed information for /rest/api/2/project/search, please visit below link  https://docs.atlassian.com/DAC/rest/jira/6.1.html#d2e4071

If you want to fetch the list of projects please refer to the below link.

https://community.atlassian.com/t5/Jira-questions/How-to-list-all-projects-a-user-has-access-to-using-Jira-s-REST/qaq-p/423593

 

Thanks,

Santwana

Suggest an answer

Log in or Sign up to answer