How do I upload an attachment to an issue via powershell?

CharlesBastian July 28, 2015

I have been searching online for a while and I've not found a solid answer to this (lots of partial answers, though).  Still nothing I do works.

I'm trying to write a powershell script to send attachments to JIRA using cURL (have not found another way that I can get to work).

My cURL command is:

C:\opt\curl\curl.exe -u user:pa$$word -X POST -H "X-Atlassian-Token: nocheck" -F "file=@C:\opt\attachments\75391_testingPNG.png" http://jira.ourURL.com/rest/api/2/issue/75391/attachments

 

This works perfectly from the command line.  Anytime I try to run it via powershell it bombs out.  Seems like it should be very easy to do, though.  Just want to grab the files from a directory and send them to JIRA.

Anyone have any thoughts about this???  Thanks!

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
CharlesBastian July 29, 2015

With some assistance from someone on StackOverflow, we figured this out.

Start-Process C:\opt\curl\curl.exe -argumentList "-u", "user:pa`$`$Word", "-X", "POST", "-H", "`"X-Atlassian-Token: nocheck`"", "-F", "`"file=`@C:\opt\attachments\75391_testingPNG.png`"",  "http://jira.ourURL.com/rest/api/2/issue/75391/attachments"

Thanks.

0 votes
Betsy Walker {Appfire}
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.
July 29, 2015

Glad you figured it out, @Charles Bastian.   Another option – just for future reference – is the JIRA Command Line Interface (CLI) add-on, which allows you to do anything that is exposed by JIRA's APIs. Its supported actions include addAttachment, getAttachment, getAttachmentList, removeAttachment, runFromAttachmentList, and many more.

TAGS
AUG Leaders

Atlassian Community Events