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

Using personal access token to make REST APi call

Hi,

We use Jira on-prem and I am attempting to automate the export of a saved search query to csv. I have tried both Power Query in Excel and PowerShell. 

I was initially successful when using Power Query to retrieve the information, with my username/password specified as part of the process. However, this has since stopped working (400 error) since I tried to replace my password with the personal access token. Now it won't work even if I revert back to using my username and password, after clearing the local/global cache and resetting captcha. (Totally regret trying to change something that was working fine!!!)

This led me to try automating the process fully in PowerShell via Basic authentication with a base64 encoded username and password. When captcha is triggered I get a 403 error as expected, but a 401 error when captcha is reset. Script is as follows (note: i haven't tried piping the output into a CSV yet and may try a direct 'export to CSV' link in place of the current URL):

$user = 'username'
$token = 'token'

$pair = "$($user):$($token)"

$encodedCred = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($pair))

$basicAuth = "Basic $encodedCred"

$Headers = @{
Authorization = $basicAuth
}
Invoke-WebRequest -Uri 'https://<base_url>/rest/api/2/search?jql= <saved filter>`
-Headers $Headers

Interestingly when I check the usage of my token via the Jira UI, there is no record of it being used under the "last authenticated" column. Is there anything else that needs to be enabled for this to work?

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events