Automation for Jira - Send web request using Jira REST API

61 comments

Michael Savedra May 23, 2022

@Ignacio Pulgar @Cristiano Hi guys,

What would be the best way to pull a user's account ID within a rule by passing through their email as free text?

I'm thinking to use a GET request with url:

myJiraUrl/rest/api/2/user/search?query={{custom field with email free text as smart value}}

but I'm not sure how to then cal upon the account Id I receive form this in the rule to then assign to a reporter field in a different ticket?

Any help would be much appriciated.

Thanks!

zac.metin@xero August 24, 2022

@Cristiano it might be good to remove this part:

2. Then we need to encode the credentials "<EMAIL>:<API_TOKEN>with base64. We can make this through any online tool like Base64 encode.


I don't think it should be suggested to people to put their (presumably Admin) Jira credentials into "any online tool" for security reasons...

Like # people like this
Kevin Cassidy October 18, 2022

I found a bug with this - if the data being sent has inverted commas ", Jira fails to parse it correctly. It gets sent to my API endpoint as a string instead of a JSON object. 

Tony Villa-Cruz
Contributor
November 3, 2022

Is this still possible? When I attempt to do this, I am getting this error:

Screen Shot 2022-11-03 at 6.19.51 PM.png

It looks like Basic Auth is no longer available...Is there an updated way to make this work?

Like Oliver Werner likes this
zac.metin@xero November 3, 2022

Hey Tony, you can still use Basic Auth, you just have to use an API token instead of a password:

https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/

Tony Villa-Cruz
Contributor
November 4, 2022

Yeah I saw that same documentation, but I am in fact using an API token and not my password and it is still giving me the same error:

 Screen Shot 2022-11-03 at 6.19.51 PM.png

Like Oliver Werner likes this
zac.metin@xero November 6, 2022

Are you using full email instead of username? I think if you just use username it thinks you are not using a token even if you are

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 29, 2022

Is it possible to pass the name of a confluence page over and the space and use the DELETE method.  I keep getting a 405 error but assume I am doing something wrong in the custom data.

Oliver Werner February 16, 2023

Hi all,

This worked for me until I recently rotated the API token in https://id.atlassian.com/manage-profile/security/api-tokens. The new API token is longer than the old one, but I'm not sure if that is what's causing the issue.

When I try to validate my WebRequest with the updated API token (based64 encoded with my username) it sends back the following payload: Basic authentication with passwords is deprecated. For more information, see: https://developer.atlassian.com/cloud/confluence/deprecation-notice-basic-auth/

I do not understand this error as I use an API token instead of a password, and as far as I am aware I have to use "Basic " before the encoded API token to make it work.

I double checked the encoded password, and the API token is valid as it was used by another request without issues.

Any insights on what I might have missed?

Thanks in advance!

- Oliver

Ignacio Pulgar
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 21, 2023

Hi @Oliver Werner ,

Try using the email address instead of a username, and the API Token as a password.

Hope it helps.

Zaldy Parian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2023

@Cristiano ,

I would like this to work with our Jira instances. But I can't seem to understand what exactly I will put in the fields of Send web request action. I tried, in base64 typing <my email>:<API Token>. And that is a far as I could go (not sure if what I did was right).

webhook.png

Samrat Ghosh
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 15, 2023

Is it possible to send more than one web request and combine Webhook responses?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 15, 2023

Hi @Samrat Ghosh 

You may call web requests as often as you wish, but not combine responses as how you describe. 

Instead you could make a web request, saving the response in either a created variable (as text) or in a Lookup Table (as JSON), make another web request, and use the results together, as needed.

Kind regards,
Bill

Ankit Rastogi
Contributor
June 22, 2023

hi @Cristiano ,

 

I am using this Web Request Jira Automation to trigger external API (Other than Jira APIs) and it's working fine with me. But to use this solution permanently I need to hide Authorization credentials because it is very easy to decode so is there any solution to hide it or we can place credential somewhere else?

Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 29, 2023

Hi @Oshri Mahlev , is this interesting for you?

Oshri Mahlev June 29, 2023

HI @Marco Brundel , Thank for your reply.

I already saw this topic, Unfortunately it doesn't help me. Im trying to have token the refresh automatic once a while.

Israel Urbina
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 8, 2023

Is it possible to use "Authorization: Bearer" instead of "Authorization: Basic" if possible, how would it be?

Like Steven Cavanagh likes this
David Proux
Contributor
November 9, 2023

@Israel Urbina You absolutely can do a Bearer token. Set it up the same way and just replace "Basic" with "Bearer" and provide the bearer token after.

Emanuele Mariani February 16, 2024

We would like to do this: call bamboo server via tunnel, but it now works.. could you please vote this issue?

[AUTO-1122] Allow Jira Automation to Send Web Request through an Application Tunnel - Create and track feature requests for Atlassian products.

ian
Contributor
February 16, 2024

@Emanuele Mariani is the Jira Edge Connecter (Use Jira automation with Jira Edge Connector (JEC) | Cloud automation Cloud | Atlassian Support) a way to do this? Although you seem to have found a way as you said, "it now works". 

Emanuele Mariani February 17, 2024

Hi Ian, 

thank you vm for your answer, we contacted the support via ticket and they said that it not works and open the ticket AUTO-1122

we will try your suggestion and let you know

Thank vm

Ema

Emanuele Mariani February 18, 2024

HI Ian

for our understanding the solution that you proposed should not works due to the problems is that only "core products" can use the tunnel the others (like automations) no. So any solution is blocked if Atlassian  don't make same changes.

If I don't understand what you're saying, please.. help me.

Bye

Ema

ian
Contributor
February 18, 2024

Hello Ema. I've not actually used JEC yet, don't know anything about how Bamboo works and not exactly sure what you're wanting to do.

I suspect you already understand this but in case it helps: 

  • JEC is a one direction only connection as far as I can tell. I don't think its possible to send data back to cloud from on-prem through the JEC if that is what you're trying to do. There are of course other ways to get data from on-prem to cloud though which I'm sure that you're already aware of. 
  • JEC is also not a direct connection from Atlassian cloud apps to on-prem Atlassian apps. If you can execute on-prem PowerShell (for example) scripts against the on-prem Bamboo server (does the Bamboo server have an API?) then I was wondering whether you could use JEC to trigger an on-prem script that would do what you are wanting with your Bamboo server.

I'm also not a Jira expert so I apologise if I'm confusing things or sending you down a wrong path.

Mahajan, Jatin March 22, 2024

I have to rotate my Token , and I have 2000+ automation in my JIRA site , Do we have any option to create secret in JIRA cloud and user the same key in all automation so that at the time of key rotation i just need to update my secret. I see this functionality available in JIRA DAtacenter version but not in cloud . 
Any way out to have similar feature in JIRA cloud? 

Vini Savi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 28, 2024

Awesome document! Thank you @Cristiano for this! solved my challenge. @Cristiano +++++++

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events