Andrey Luiz
Andrey Luiz

Reputation: 471

How to retrieve the Project Key by Project Id programmatically in Jira?

I need to get the project key (or keys) programmatically.

The only alternative to retrieve the project keys I found was the content on this page:

https://confluence.atlassian.com/display/JIRA/Editing+a+Project+Key#EditingaProjectKey-Notesfordevelopers

There it says:

What I need is to retrieve the key(s) by project id.

Is there an easy way to do this? How can I know which key correspond to which project id?

I'm using Jira version 6.4.3 and Atlassian Plugin SDK version 5.0.13.

I am using the SAL Services. Is there any better option?.

Upvotes: 1

Views: 3609

Answers (1)

Ram
Ram

Reputation: 66

there is no direct method to get keys with id but you can get Project object with id ad then you can get the project key from Project object

if you want to get project object for a id then try with https://docs.atlassian.com/jira/latest/com/atlassian/jira/project/ProjectManager.html#getProjectObj(java.lang.Long)

if you want to get Project objects for multiple project id's then try with this https://docs.atlassian.com/jira/latest/com/atlassian/jira/project/ProjectManager.html#convertToProjectObjects(java.util.Collection)

i hope the above links will help you!!

Upvotes: 3

Related Questions