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,116
Community Members
 
Community Events
184
Community Groups

Add API authentication into an automation send web request

I want to use automation to send a REST API - in automation language a Send web request action - but I need to be able to authenticate using an API Key from the receiving platform. 

Here's the authentication documentation from the receiving platform:

image.png

How can I insert this API key in the automations Send web request?

2 answers

2 accepted

0 votes
Answer accepted
Tony Langlet
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.
Apr 24, 2023 • edited

Hello @Ward Schwillens_ Schwillie 

As @Stephen Wrathall mention you need a base64 auth token generated based on the username and password, I'm not the biggest fan of curl but can provide a Powershell script that will provide the authtoken.

 

$atlassianUsername = <Username>
$atlassianPassword = <Password>
$atlassianAuthToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes("$($atlassianUsername):$($atlassianPassword)"))

 


 

Once you've got that you're able to use the authtoken in a Jira Automation Send Webrequest.

You have to change the web request URL to match what your looking for and the HTTP method to match the endpoint. 

2023-04-24 10_41_03-Automation - Jira.png

Once you get a response you'll have to handle it some how, this is how the above web request is being managed to create a variable for the user. I placed the response in a variable to be able to reuse it throughout the automation. 

2023-04-24 10_23_20-Automation - Jira.png

 

I hope I managed to give you some insight in how you possible could work with the web request.

Stephen Wrathall
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 24, 2023

Thanks @Tony Langlet. Minor note that:

applicaiton/json

needs to change to:

application/json

for the "Accept" header in your screenshot.

Tony Langlet
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.
Apr 24, 2023

Thanks, I've updated the screenshot, I copied data from a production automation to a test automation and thought my accuracy was good enough to write one word :D

Like Stephen Wrathall likes this

Thanks Tony,

I found another way to generate the base64 encoded auth token based on the username and password. The basic authentication with the API key and the "X" worked fine.

I'm now updating freshservice tickets with this API call when specific updates occur in the Jira issue. 

Best regards, Ward

Like # people like this
0 votes
Answer accepted
Stephen Wrathall
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Apr 21, 2023

Hi @Ward Schwillens_ Schwillie,

"-u" is curl's way of specifying Basic Authorization. There is an article explaining how to achieve this in detail here:

https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

To summarise for your case, you'll want to Base64 encode your "<username>:<password>" by running:

echo -n "abcdefghij1234567890:X" | base64

(or an equivalent base64 encoding tool)

and then adding a header to your Web Request with:

Key: Authorization

Value: Basic <your_base64_encoded_output_from_above>

I hope this helps!

Thank you for explaining Stephen. I found a base 64 encoding tool to do this for me.

Best regards, Ward.

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events