Searching for the project by name via API

Inna S
Contributor
August 22, 2022

Greetings!

For one of the automation tasks I need to get a project ID.

What I have is a project name and an API.

Unfortunately, the documentation https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-search-get does not explain how to search for the project by name.

Google search does not help either.

The most funny answer was this:

jira_searchProjectIDAPI.jpg

So we spent some time experimenting and at the end found the obvious:

to find a Jira Project by NAME, use the following API call:

https://<your instance>.atlassian.net/rest/api/3/project/search?query={{ProjectName}}

where {{ProjectName}} is a custom variable you have defined in a previous step.

Enjoy.

3 answers

1 vote
Inna S
Contributor
August 25, 2022

Hi @robert Mugabuhamye , the point of this post was to demonstrate how we have done the thing. 

So this is possible, just not properly documented in the API doc.

You are welcome to test for yourself.

Influential Eliot
Contributor
December 4, 2024

Hey, I know this is old, but I thought that I would leave this here for anyone that's working on anything Jira related for these kinds of things.

I've noted that via the GUI the projects list sends a POST request to the following path on your tenancy:

/gateway/api/graphql/pq/AUTHENTICATION_CODE_OR_SOMETHING?operation=ProjectDirectoryRefetchQuery

( where 'AUTHENTICATION_CODE_OR_SOMETHING' seems to be some authentication )

This sends a JSON body with the following:

{
"operationName": "ProjectDirectoryRefetchQuery",
"variables": {
"cloudId": "SOME_RELEVANT_ID_I_HAVE_NOT_RESEARCHED_WHICH",
"filter": {
"keyword": "SEARCH_PHRASE",
"sortBy": {
"order": "ASC",
"sortBy": "NAME"
}
},
"first": 25,
"isAdminSettingsContext": false,
"last": 25
}
}

( where 'SEARCH_PHRASE' is whatever you placed into the filter box above the project list )

So ... perhaps similar endpoints can be sourced within the API itself.

0 votes
robert Mugabuhamye
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.
August 25, 2022

My bad @Inna S . thank you 😊🙏

0 votes
robert Mugabuhamye
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.
August 24, 2022

Hello @Inna S ,

You can not filter by project name. You get all the projects and then you can loop in that list to find what you are looking for.

If you know the key/Id you can use it : /rest/api/3/project/{projectIdOrKey}.

Hope it helps.

Influential Eliot
Contributor
December 4, 2024

Sorry, but surely this is slightly weird.

Like, how am I supposed to search (via API and JQL in the GUI) for a Project by using part of it's name?

Am I really expected to do one of the following:

  • API - Get all project names and filter independently
  • GUI - Literally download all of the Project Names + Keys into a spreadsheet and filter that?

Because both of those are (respectively to their environment) a silly amount of work for a client/user to be expected to do.

This really does seem like basic stuff that should be doable out of the box.

Suggest an answer

Log in or Sign up to answer