My jira server's version is v8.5.6. When I call the rest api Get valid project key, it doesn't work.

Ronaldo Huang November 12, 2020

I see the document: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-key-and-name-validation/#api-rest-api-3-projectvalidate-validprojectkey-get

I want to Get valid project key.

When I call the rest api which uri is /rest/api/latest/projectvalidate/validProjectKey

the response is <?xml version="1.0" encoding="UTF-8" standalone="yes"?><status><status-code>404</status-code><message>null for uri: http://mydomain/rest/api/latest/projectvalidate/validProjectKey?key=HSP</message></status>

2 answers

1 accepted

0 votes
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 12, 2020

Hi @Ronaldo Huang I checked the endpoint on CLoud it it is working as documented. I think you have Server/Cloud problem. I guess you are on Server (at least your question is created with "jira-server" attribute, but the documentation is for Cloud version of Jira.

There is similar endpoint for server but it probably only validates project key and do not suggest valid one:

https://docs.atlassian.com/software/jira/docs/api/REST/8.13.1/#api/2/projectvalidate

Ronaldo Huang November 12, 2020

@Martin Bayer _MoroSystems_ s_r_o__ 

Hi, how can I get a suggested valid key from my local jira server by rest api which is like GET /rest/api/3/projectvalidate/validProjectKey on cloud?

Only 'GET /rest/api/2/projectvalidate/key' which validates project key is avaiable in the document above.

Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 13, 2020

Hi @Ronaldo Huang I don't think it is possible. I'm checking it on old Jira (7.6.x) and it looks like when new project is going to be created, the "key" suggestion is done by JavaScript on frontend and it is validate using mentioned endpoint and it does not provide valid KEY in the response.

I think you will have to do it programatically... for example

only schema of the code

def key = suggestedKey
while(!isValid(key)){
key = incrementKey(key)
}

You have to implement methods 

  • incrementKey with the code which will check if KEY ends with number and if so, split it and add number+1 and check again
  • isValid which will validate existence of key using endpoint in my previous response
Ronaldo Huang November 13, 2020

Thank you for your suggestion. @Martin Bayer _MoroSystems_ s_r_o__ 

0 votes
Kian Stack Mumo Systems
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 12, 2020

Those are cloud API paths.

Try this endpoint -

/rest/api/2/projectvalidate/key

You can see the API's available for your version here.

Suggest an answer

Log in or Sign up to answer