Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,010
Community Members
 
Community Events
184
Community Groups

How to obtain current project id(key) using rest call?

Capture.PNG

2 answers

1 accepted

0 votes
Answer accepted
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.
Mar 02, 2017

What is the "current project id" in the context of a REST call?

Unless you are pulling back an issue, in which case you can read the project from the issue, then there is no context for any particular call.

The "id/key" of the selected project.Capture.PNG

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.
Mar 02, 2017

That's a user session, nothing to do with any REST call you might be making somewhere else.

Robert Massaioli (Atlassian)
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Mar 05, 2017

Dasuni: why are you trying to get the "current project id"? When you have that information what will you do with it? Maybe if we knew what you were trying to do we could give you a helpful answer instead of one that is essentially: "Don't rely on that information, you can't get it via REST.".

I want to get document_ids of current project into an combo-box in the dashboard. To do that I want to know the current selected project_id. 

Currently I am following an approach. Via following rest call ( then extract the Key using algorithm )

/rest/api/1.0/menus/browse_link.json?inAdminMode=false

Will it be successful  Always?

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.
Mar 06, 2017

No, because there is no context.  You need to think through what current project id really means.

Consider two users - Hattie the human and Robbie the Robot.

Hattie logs into JIRA with her browser, and goes to visit issue ABC-123.  "Current project" makes sense to her, because she's using it in the context of a browser session that has just looked at an issue within a project.  You can say her current project is ABC until she goes to another project, moves to a non-project context (admin screens, profile, etc, and even then you could argue "last one she looked at") or a mixed-project context such as a dashboard or filter (what's the current project when your screen is showing you ABC-123 and DEF-123?)

Robbie the Robot logs into JIRA and performs a REST call that does something.  He's not using a browser or anything else with an active context.  If he's read/updated ABC-123, then yes, you can assume current project is ABC, but his REST call is complete - you have to handle that assumption on your side.  And if Robbie's REST call does not return something that is clearly "current project", such as a profile or admin function, then you have no "current project"

So, I ask again - what do you think "current project" actually is?

For anyone looking for this specifically, I found the same API call that @Dasuni Kumarapperuma mentioned to be really the only reliable way to get current project from the JIRA API: rest/api/1.0/menus/browse_link?inAdminMode=false

 

Reason why I personally need this is we have an issue searcher custom field that looks at "currentproject()" in its JQL, if I'm pushing a bunch of issues via rest and this field gets invoked, I need to make sure my users are in the correct project so my script doesn't bomb.

I was using just the regular JQL api call to get one issue from the project and read the project ID, but this only works if the project has issues, for a brand new project, this doesn't work.

And for some reason the /project/recent tries to find a project with the id of "recent" as opposed to the atlassian documentation that states that it retrieves recent projects.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events