Create Project from API

Ravinder Avala May 11, 2016

I noticed that /rest/api/2/project requires 'key' as in input, is there a way to force 'key' value to be generated by JIRA itself for the sake of uniqueness so that we don't need to pass that value?

The problem is  - we are running into errors due to duplicate keys. In order to avoid duplicate 'key' issue we have to make an extra call(s) which to me is inefficient. If there is a 'key', then we should again check for a second 'key' and keep going until we find a unique - which is too much. Is there a way to avoid this situation.

Secondly - how long the key can be?

2 answers

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2016

No, the call really does just do "create with key given".  The UI has a bit of code in it that suggests new keys from the description (and it won't suggest duplicates), but that is not something you can use in REST.

A project key has a default maximum length of 10, although that can technically be changed (not recommend though, longer keys get truncated in displays and it may still break some add-ons)

0 votes
Jeremy Gaudet
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.
May 11, 2016

 The project key is supposed to be descriptive... by which I mean, it's something specific to the intent of the project to help you identify it.  If the project is, say, for documentation, you want the key to be something like "DOC", not something random like "ABC123"; that way, when you get email for issue DOC-764, you know what it's about without having to look up what project "ABC123" represents.  What is the system attempting to accomplish?  If it's proxying 'create project' requests for users, perhaps you should have them request a key at the same time?

The longest key I've (seen) used is 10 characters; it can probably go longer, but you don't really want them to be too large to fit in the email subject line.

Suggest an answer

Log in or Sign up to answer