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

Download or Export all field issues of Jira via PowerShell

Mike Minguell Pont July 22, 2015

Hi all, im trying to download via powershell to make an automatic task every friday. Im using this script but it stays at the login page. 

I have made many scripts but none of them worked as i want, they download me the login page.

$webClient = new-object System.Net.WebClient
$creds = New-Object System.Net.NetworkCredential ("user", "password")
$url = "http://localhost:8080/sr/jira.issueviews:searchrequest-excel-all-fields/10000/SearchRequest-10000.xls?"
$localfilename = "C:\Users\mminguel\Documents\WorkLog2.xls"
$cache = new-object System.Net.CredentialCache
$cache.Add($url, "Basic", $creds)
$webclient.Credentials = $cache
$webClient.DownloadFile($url, $localfilename)

 

or 

 

$source = "http://localhost:8080/sr/jira.issueviews:searchrequest-excel-all-fields/10000/SearchRequest-10000.xls"
$destination = "C:\Users\mminguel\Documents\WorkLog4.xls"

Invoke-WebRequest $source -OutFile $destination

Thanks!

 

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Hamish Blake August 4, 2015

This is what I use to do JIRA API querying via PowerShell:

function Encode-Credentials([string]$username, [string]$password) {
  $credentials = "{0}:{1}" -f $username, $password
  $bytes = [System.Text.Encoding]::UTF8.GetBytes($credentials)

  return [System.Convert]::ToBase64String($bytes)
}
 
$url = "<url>?jqlQuery=project in (project1, `"project two`") and sprint in openSprints()&tempMax=1000"
$request = [System.Net.WebRequest]::Create($url)
$request.ContentType = "application/json"
$request.Method = "GET"
$credentials = Encode-Credentials -username "me" -password "mypassword"
$request.Headers.Add("Authorization", "Basic " + $credentials)
$response = $request.GetResponse()
$stream = $response.GetResponseStream()
$sr = New-Object System.IO.StreamReader $stream
$sr.ReadToEnd() | Out-File C:\Path\file.xls

Hope that helps.

 

 

NotTheRealStephenSifersNOPENOPENOPENOPE
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.
October 14, 2017

Confirmed this works.

Ph July 20, 2018
TAGS
AUG Leaders

Atlassian Community Events