I am having an issue with creating an action via the API. I am using the below script which I poached form a forum and modified. I keep getting an error that the Action does not exist which I kind of figured since I am trying to create it. The output from running the file is below too.
$body2 = @"
<?xml version="1.0" encoding="UTF-8"?>
<BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BES.xsd">
<SourcedFixletAction>
<SourceFixlet>
<Sitename></Sitename>
<FixletID>370383</FixletID>
<Action>TempAction</Action>
</SourceFixlet>
<Target>
<ComputerName>769623</ComputerName>
</Target>
</SourcedFixletAction>
</BES>
"@
[xml]$actions = Invoke-WebRequest -Uri "https://bigfix.spencerstuart.com:52311/api/actions" -Method Post -body $body2 -credential $creds -ErrorVariable $er
Invoke-WebRequest : {“format”:“Unexpected server error: {message}”,“arguments”:[“Action “TempAction” does not exist.”]}
At line:16 char:17
- … ]$actions = Invoke-WebRequest -Uri "https://bigfix.spencerstuart.com: …
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
- FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
Thanks!
Tony