I’m trying to download Jira issue attachments via PowerShell. All is working great on my personal cloud instance of Jira, but when I attempt to download on my client’s server Jira instance, I get a corrupted file. I believe it has something to do with credentials, but I am successfully executing many API calls against the Project/Issues with the Personal Access Token (PAT), which is used as the bearer token for authorization.
Any help would be awesome!
Here is my PowerShell scirpt:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer [PersonalAccessToken]")
$response = Invoke-RestMethod '[URL]/secure/attachment/20202/KSD GE 6109 10 11 Email.pdf' -Method 'GET' -OutFile '[FolderPath]\KSD GE 6109 10 11 Email.pdf' -Headers $headers
$response | ConvertTo-Json