Create new key while create project by API

HI All,

          How will get all project keys. Because while we create new project by API  i need to give different key. So before that i need to check all existing Key and create new Key. How will achieve this?

2 answers

This widget could not be displayed.
Vasiliy Zverev Community Champion Jan 14, 2016

Since you have a collection on project keys for each project you have to do a loop over all projects. Here is a code example how to get all project keys:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager

ProjectManager projectManager = ComponentAccessor.getProjectManager();

List<String> prjKeys = new ArrayList<>();

for(Project project: projectManager.getProjectObjects()){
    prjKeys.addAll(projectManager.getAllProjectKeys(project.getId()))
}

return prjKeys.toString()
This widget could not be displayed.

can you please share your code.. I'm also working on something related to this

 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted yesterday in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

45 views 2 2
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you