I am trying to attach a txt file from my local computer to Jira issue using Invoke-Restmethod and i am getting following error
Invoke-RestMethod : The remote server returned an error: (415) Unsupported Media Type.
At C:\scripts\jira4.ps1:30 char:15
+ $newstatus = Invoke-RestMethod -Method POST -Headers $headers -ContentType "tex ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
I am using following command to run it
$newstatus = Invoke-RestMethod -Method POST -Headers $headers -ContentType "text/html;charset=UTF-8" -InFile $ticketfile -uri "$target/rest/api/2/issue/$key/attachments"
No matter what i change for "Contenttype" i still get the same error.