How to get project's numeric id?

Added by Paweł Hikiert over 4 years ago

I have several projects on Redmine, let's say one of them has identifier "some-identifier-1" and name "project", and the other has identifier "project" and name "project".

I'd like to link to project page (not wiki page!) of project with identifier "project"

On this page it is written I can link to project page using following syntax:
  • project#3 (link to project with id 3)
  • project:someproject (link to project with name "someproject")
  • project:"Multiple words project" (double quotes can be used when project name contains spaces)

Linking to project:project links to project with identifier "some-identifier-1", because my Redmine (2.4.2.stable from Ubuntu 12.04) code tries to match identifier OR name, and that's the first project it finds. For now I've modified the code to first try to match project's identifier, and then project's name, but I think that's not the way it should be done.

So the question is: how to find project's id? I haven't found any information on project's settings tab, on main project page, even on administration's projects list.

Replies (12)

RE: How to get project's numeric id? - Added by dah woo over 4 years ago

I would assume you can log into your phpadmin and it gets numerically assigned there. similar to your user ID. I'm guessing there's a way to find out via linux command in the log file but

RE: How to get project's numeric id? - Added by Paweł Hikiert over 4 years ago

dah woo wrote:

I would assume you can log into your phpadmin [...]

I can. My Redmine's users can't.

RE: How to get project's numeric id? - Added by dah woo over 4 years ago

understood. Not sure how many projects you are running but if can indeed get this info from PHPadmin then why not paste it into the over/settings of the project? If it's only a few this shouldn't be a problem if it's 30+ then I could see it being tedious.

RE: How to get project's numeric id? - Added by Paweł Hikiert over 4 years ago

dah woo wrote:

[...] if it's 30+ [...]

It's much, much more.
I thought I was overlooking something about these ids, but it looks like Redmine just lacks this functionality, so I'm not able to use project#id in a simple manner.
Maybe it's worth creating an issue...

RE: How to get project's numeric id? - Added by Pavel Potcheptsov over 4 years ago

It seems that it's impossible to find out ID of a project unless you have access to database.
Maybe such ID should be highlighted when you hover mouse above any link to project, similar as link to user which looks like redmine.com/users/111 where 111 it's ID of user.

RE: How to get project's numeric id? - Added by Mischa The Evil over 4 years ago

Paweł Hikiert wrote:

I thought I was overlooking something about this ids, but it looks like Redmine just lacks this functionality, so I'm not able to use project#id in a simple manner.
Maybe it's worth creating an issue...

Pavel Potcheptsov wrote:

It seems that it's impossible to find out ID of a project unless you have access to database.

I can confirm this is a genuine issue in the Redmine core indeed. AFAIK there's only one way to retrieve (the numerical) project id's and that is via the REST API. At least the projects and project memberships resources exposes project id's at some endpoints.

RE: How to get project's numeric id? - Added by Paweł Hikiert over 4 years ago

Omitting the 'id issue' I think creating a link using a project's name is wrong, because there is no constraint that name shall be unique. Also, name could be changed, thus leading to broken links. Current code, which takes into account name OR project's identifier is not reliable, as it could lead to 'mislinks', as shown i the first post.

So, in my opinion, notation project:someproject should link to project with identifier "someproject".

I proposed a patch: #20397

RE: How to get project's numeric id? - Added by Willmore BattleShipNet almost 2 years ago

Paweł Hikiert wrote:

I have several projects on Redmine, let's say one of them has identifier "some-identifier-1" and name "project", and the other has identifier "project" and name "project".

I'd like to link to project page (not wiki page!) of project with identifier "project"

On this page it is written I can link to project page using following syntax:
  • project#3 (link to project with id 3)
  • project:someproject (link to project with name "someproject")
  • project:"Multiple words project" (double quotes can be used when project name contains spaces)

Linking to project:project links to project with identifier "some-identifier-1", because my Redmine (2.4.2.stable from Ubuntu 12.04) code tries to match identifier OR name, and that's the first project it finds. For now I've modified the code to first try to match project's identifier, and then project's name, but I think that's not the way it should be done.

So the question is: how to find project's id? I haven't found any information on project's settings tab, on main project page, even on administration's projects list.

Guys, there is some way to find out ID but it requires a little fiddling.

If you would like to know your projects ID go to redmine's URL with added "/projects.xml" and you will get all projects available to you. Lookup up for a line <name>Your project of interest</name> and the line above that will contain project id you are looking for.

RE: How to get project's numeric id? - Added by Paweł Hikiert almost 2 years ago

Marius Žilėnas wrote:

Guys, there is some way to find out ID but it requires a little fiddling.

If you would like to know your projects ID go to redmine's URL with added "/projects.xml" and you will get all projects available to you.

No, you will only get top-level projects list (at least that's how it works at my place).

Talking about .xml extension you can just add it to project name to get the xml for the project, e.g.
https://www.redmine.org/projects/redmine.xml
but that's definitively not the way you would like it to be used in "production envirionment". The interface should be for people, not for hackers.

RE: How to get project's numeric id? - Added by Willmore BattleShipNet almost 2 years ago

With projects.xml you don't see the projects that you can see in /projects ?

Good one about .xml adding to the project's name :).

RE: How to get project's numeric id? - Added by Paweł Hikiert almost 2 years ago

Marius Žilėnas wrote:

With projects.xml you don't see the projects that you can see in /projects ?

No. But the projects weren't top-levels, as I thought. Without additional arguments projects.xml shows only 25 first projects from the list.
To get the rest of them one has to use parameters like 'limit' and 'offset', as described here:
Rest_api
Anyway, as I've said before - this is not the way 'ordinary people' should do it.

(1-12/12)