Currently I’m working to upload a file to a Jira ticket using PowerShell Invoke-RestMethod. Problem is after several days of googling and playing around with some code I haven’t gotten very far.
My powershell code is below. I get a 500 error every time. But when I don’t add the no-check token I get a 403 error. Has anyone been able to get this to work in PowerShel?
All of the answers I have found are about least two years old.
$NewHeaders=$headers
$NewHeaders.Add(“X-Atlassian-Token”, “no-check”)
Invoke-RestMethod -Uri “$($URIPath)/issue/$($jiraTicket)/attachments” -Method POST -InFile $filepath -ContentType “multipart/form-data” -Headers $NewHeaders
What the variable “$headers” contains is below, which works when using it to create tickets, post comments, etc.:
Name Value
Authorization Basic exampe_token
I was thinking of building a curl command and getting it to work, then somehow translating it to PowerShell. But the problem is I’m not sure I’d run into the same issue I’m having now.
From my research, I’ve tried the following, all of which didn’t work:
http://techqa.info/programming/question/31685034/how-do-i-upload-an-attachment-to-a-jira-issue-via-powershell
Read through the following, also was unable to code a solution based on them in PowerShell: