I am trying to attach a file to Jira Issue via Rest. I have placed the header as 'X-Atlassian-Token:nocheck'
But I am not able to get the correct structure of xml to attach the file.
It gives me a HTTP 500 error.
Any help?
Community moderators have prevented the ability to post new answers.
Found the solution from Jason to resolve a similar question I had.
For all the other googlers out there that may research this in the future, this is how I got this to work for me after editing the code from Jason.
THANKS! You're the man Jason.
function Upload-JiraCSV($jiraTicket, $filepath) { $wc = new-object System.Net.WebClient $wc.Headers.Add("Authorization", $headers.Authorization) $wc.Headers.Add("X-Atlassian-Token", "nocheck") $wc.UploadFile("$URIPath/issue/$jiraTicket/attachments", $filepath) }
function Jira-UploadFile($jiraTicket, $filepath) { $wc = new-object System.Net.WebClient $wc.Headers.Add("Authorization", $Global:JIRA_HEADER.Authorization) $wc.Headers.Add("X-Atlassian-Token", "nocheck") $wc.UploadFile("$Global:JIRA_BASE_URL/rest/api/latest/issue/$jiraTicket/attachments", $(Resolve-Path $filepath)) > $null }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jason, is the $filepath local to the JIRA server? or can it be from a remote server where the script is running? the reason I ask, is because I tried your function, but is giving me "Network Path not found" How are you passing the path? I use "D:\something.html"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, the file is on whatever server. The WebClient will put its content into a POST method request. I already have in the script the Resolve-Path which will make relative paths absolute. $Global:JIRA_BASE_URL need to be set to your jira instance with a protocol header, ex: "http://myjira:1234";. The $Global:JIRA_HEADER.Authorization is the Base64 of username:password like all the authorized API calls need.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.