#Create an object to store the headers
$headers = New-Object "System.Collections.Generic.Dictionary[[String],
[String]]"
#Add Header Name, Value
$headers.Add("X-Redmine-API-key",'xxxxxxxxxxxxxxxxxxxxxx')
$headers.Add("Content-Type",'application/json')
$uri="https://redmine.company.com/issues"
$json=C:\scripts\ticket.json
#Calls the API
Invoke-RestMethod -Method Put -Headers $headers -Uri $uri
Invoke-RestMethod : Page not found
The page you were trying to access doesn't exist or has been removed.
Back
At line:21 char:8
+ $oData=Invoke-RestMethod -Method Put -Headers $headers -Uri $uri -
ContentType 'a ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation:
(System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId :
正如我在标题中所述,我试图使用REST API使用powershell更新带有json文件的票证。该错误声称我使用的URI不正确,但如果修改代码并使用GET,它就可以正常工作。有没有人试过这个或者有类似的东西我可以作为起点?
答案 0 :(得分:0)
According to their documentation
$Headers = @{ 'X-Redmine-API-key' = 'xxx' }
$Body = Get-Content -Path C:\scripts\ticket.json -Raw
$Uri = 'https://redmine.company.com/issues/<ENTERIDHERE>.json'
$R = Invoke-RestMethod -Headers $Headers -Body $Body -Method PUT -Uri $Uri -ContentType application/json
$R