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


1 answer

1 accepted

Accepted Answer
0 votes

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

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

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 )


Will it be successful  Always?

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?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published yesterday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

301 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you