jasmeet24
jasmeet24

Reputation: 656

How to get "Project Id" to create a Direct Link?

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.

Upvotes: 36

Views: 28884

Answers (4)

sebnukem
sebnukem

Reputation: 8323

This solution does not require admin rights:

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

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

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


Bonus one-liners:

Get the project Id (with cUrl and jq):

curl -s -H "Content-Type:application/json" "https://jira.YOURDOMAIN.TLD/rest/api/2/project/PROJECTNAME"|jq -r '.id'

(An empty answer probably means that your JIRA server requires authentication.)

List all the visible projects and their Id:

curl -s -H "Content-Type:application/json" "https://jira.YOURDOMAIN.TLD/rest/api/2/project"|jq -r '.[] | .key + " = " + .id'|sort

Upvotes: 63

barryku
barryku

Reputation: 2584

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>

Upvotes: 2

Daria Trainor
Daria Trainor

Reputation: 5575

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

Upvotes: 39

Richard Christensen
Richard Christensen

Reputation: 2166

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"
        }
    }
]

Upvotes: 4

Related Questions