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

How to extract Organizations's auto-generated internal ID's

Tom Daudelin March 24, 2022

Hello all, in jira service management for each ticket we require users to declare their organization. Through Jira automation rule we would like to extract the internal jira ID for their organization (I am refering to the auto generated ID that is stored somewhere by Jira).
How can I query or extract that ID? And just out of curiosity where is this table being stored and how else could I access it?

Thank you very much,

-Tom

1 answer

1 accepted

2 votes
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 24, 2022

You can get the ID via the REST endpoint Get organizations, and then you would have to iterate those orgs in order to find the one the user belongs to using the Get users in organization endpoint. 

Tom Daudelin March 25, 2022

Hey Mikael, thank you for the quick response, do you know how I could extract an access token/bearer token for the request to go through?

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2022

Go to id.atlassian.com and log in with the account you want to generate the token for, then go to Security and from here you can generate it.

Tom Daudelin March 25, 2022

Thank you so much! I will try it all out!

Like Mikael Sandberg likes this
Tom Daudelin March 25, 2022

Hello Mikael, I have tried generating a token, and even got a web admin to generate a token, however we both get 401 Unauthorized error. Do we need the top admin (i forget the term i think its gov admin) to generate a token for this to work?
Otherwise, is there any way we could access or query this table without a REST call that would still work with Jira automation?
Thank you so much for your help and time.

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2022

The permission for the Get organizations says anyone can do it, except if you fetch it using the accountid for the users, then you have to be a JSM agent. The 401 error indicate that you are not logged in. Make sure you are including the headers in the web request, like this:

Screen Shot 2022-03-25 at 2.17.16 PM.png

The documentation says to use Bearer, but that is only if you use OAuth authentication in a connect app. Since you are using a user you have to use Basic the email:token, like this: fred@example.com:<token>

I use encode64 to encode the credentials as an extra precaution.

Tom Daudelin March 28, 2022

Hello Mikael, thank you so much for the information!!
This looks very promising. I will let you know how it goes!

Like Mikael Sandberg likes this
Tom Daudelin March 28, 2022

Hey Mikael,

thank you again for all of your help and patience with me its much appreciated :)
I am not able to get any data back in the jira automation and I think it is because I am not doing the right Autorization for an API token. I still see a 401 error saying that the Basic authorization is depricated.

I am however able to get data when doing a curl call using my token:


curl -v https://[baseURL].atlassian.net/rest/servicedeskapi/organization --user [myEmail]:[myAPIToken]

how can I translate this into my Jira Automation REST call?

I have tried Authorization:  Basic [myEmail]:[myAPIToken] but this gives me 401 error

 

thank you again for your patience,

Tom Daudelin

Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 28, 2022

Okay, so it looks like you have to encode your email address and token for it to work. I just tried it in my sandbox environment and the validation of the web request was successful

Screen Shot 2022-03-28 at 2.30.52 PM.png

Tom Daudelin March 28, 2022

YOU ARE A LIFE SAVERRR!!!
thank you so much for all of your help!!
I have tried it on my end and it works too!

Thank you so much again :))

Tom Daudelin

Like Mikael Sandberg likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events