36

I have my project name, but not the numeric Project Id. The latter is needed to use HTML Direct Links.I'm using JIRA 5.0.1

How do I get the numeric Project Id for a given project name?

I've searched the Project Administration area, several other places, the documentation, Google, etc but still can't find a way to get that value.

Thanks.

glglgl
  • 89,107
  • 13
  • 149
  • 217
jasmeet24
  • 676
  • 3
  • 10
  • 24
  • I googled it and found out this link. http://jira.atlassian.com/secure/CreateIssueDetails!init.jspa?pid=10420 to create JIRA issue using HTML link. But when i created my project with some name 'ABC' , i cannot get that pid=xxxx.... just wanted to know from where can i get that pid from ? – jasmeet24 Mar 28 '12 at 05:50
  • and whenever i run that link on localhost i get this error : You have not selected a valid project to create an issue in. – jasmeet24 Mar 28 '12 at 05:54

4 Answers4

62

This solution does not require admin rights:

Navigate to https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME and read the id in the JSON response:

{
    "self":"https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME",
    "id":"12345",  ☜ Project Id
    "key":"YOURPROJECTNAME",
    "description":..
    :
}

Navigate to https://jira.YOURDOMAIN.TLD/rest/api/2/project to get a JSON list of projects.

Bonus: here's a one-liner in Groovy to get the ID:

groovy -e "println new groovy.json.JsonSlurper().parseText("https://jira.YOURDOMAIN.TLD/rest/api/2/project/YOURPROJECTNAME".toURL().text)?.id ?: 'not found'"

A java.io.FileNotFoundException probably means that your JIRA server requires authentication.

Here's a one-liner to list all the visible projects and their ID:

groovy -e "new groovy.json.JsonSlurper().parseText('https://jira.YOURDOMAIN.TLD/rest/api/2/project'.toURL().text)?.each{println it.key+' = '+it.id}"
sebnukem
  • 8,143
  • 6
  • 38
  • 48
  • 5
    This one worked for me - I couldn't find the Admin page mentioned in the top answer. – ninhenzo64 Apr 22 '14 at 22:10
  • 4
    This solution doesn't require administrative permissions for JIRA to access. – Chris Arena Apr 29 '14 at 19:24
  • 1
    With this one (the best for me), you can found all key value for direct jira creation : _components_, _issuetype_ supported by project, etc. So good :) – Alix Lourme Dec 03 '14 at 21:10
  • 1
    Agreed, this should be the accepted answer since it doesn't require special permissions. Thanks for this! – Sensei_Shoh Jan 28 '17 at 03:07
  • 1
    Thank you! Only solution I was finding was the "Edit Project" one, but I didn't have permissions to see that button. This helped. – Mathieson Mar 31 '17 at 21:26
39

The easiest way is to do it from the web browser:

  1. Go to the Administration page.
  2. Select the Project from the menu.
  3. Hover over 'Edit Project' link and check the link href (in the status bar).
    It should be something like http://servername:8080/secure/project/EditProject!default.jspa?pid=10040

Where pid is the id you are looking for.

For Jira 6.x:

  • place the cursor on EDIT Project button and
  • look at the url being redirected at bottom left of the screen
ppolyzos
  • 6,791
  • 6
  • 31
  • 40
Daria Trainor
  • 5,545
  • 4
  • 23
  • 30
3

This solution doesn't require admin rights and shows you all of the projects the current user can view.

https://example.com/rest/api/2/project

Responses found here.

https://docs.atlassian.com/jira/REST/latest/#d2e4972

returns a json array.

[
    {
        "self": "http://www.example.com/jira/rest/api/2/project/EX",
        "id": "10000",
        "key": "EX",
        "name": "Example",
        "avatarUrls": {
            "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
            "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
            "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
            "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
        },
        "projectCategory": {
            "self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
            "id": "10000",
            "name": "FIRST",
            "description": "First Project Category"
        }
    },
    {
        "self": "http://www.example.com/jira/rest/api/2/project/ABC",
        "id": "10001",
        "key": "ABC",
        "name": "Alphabetical",
        "avatarUrls": {
            "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10001",
            "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10001",
            "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10001",
            "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10001"
        },
        "projectCategory": {
            "self": "http://www.example.com/jira/rest/api/2/projectCategory/10000",
            "id": "10000",
            "name": "FIRST",
            "description": "First Project Category"
        }
    }
]
Richard Christensen
  • 2,046
  • 17
  • 28
2

Exporting a ticket in XML reveals the project ID for me. I am not admin, so can't access the admin page. The rest/json trick didn't work for me, either. The XML of an issue has the following,

<project id="1234" key="test">TEST Project</project>
barryku
  • 2,496
  • 25
  • 16