我正在尝试使用Powershell将文件附加到Jira。我能够使用Chrome扩展程序“Postman”附加文件。使用我尝试将其实现为PowerShell的变量。但是,我收到以下错误消息
Invoke-RestMethod:远程服务器返回错误:(500)内部服务器错误。
我的代码如下。如果有人能提供帮助,我将不胜
谢谢,
$uri = "myserver.net/apps/jira/rest/api/jiraissue/attachments"
$username = "username"
$password = "password"
$file = "C:\test\files\jira.txt"
$attachfile = @{body=@{File="$file"}}
$Json = ConvertTo-Json $attachfile
$creds = @{
"Authorization" = "Basic "+[System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($username +":"+$password))
"X-Atlassian-Token"="nocheck"
"Charset"="UTF-8"
}
Invoke-RestMethod -Uri $uri -contenttype "multipart/form-data" -headers $creds -Method Post -body $Json