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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Using personal access token to make REST APi call

Eunice I'm New Here Oct 06, 2021


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
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

516 views 16 17
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you