Question

API worklet execution

  • 25 November 2022
  • 3 replies
  • 47 views

Badge

 

Hi Everyone.

 

I’m trying to execute a worklet  through the APPI but Im only getting a bad request error. 

Any idea what could be wrong ?

 

$polid = MyPolicyWorkletID

$headers = @{ "Authorization" = "Bearer $apiKey" }

$url = "https://console.automox.com/api/policies/$polid/action?o=MyOrgID"
$body = @"
  {
      "action": "remediateServer"
      "serverId": "MyServerID"
  }
"@

Invoke-WebRequest -Method POST -Uri $url -Headers $headers -Body $body
 

Thanks for any help !!

Diego

 

 


3 replies

Badge

 

Updated, still getting same error. 

 

$polid = MyPolicyWorkletID

$headers = @{ "Authorization" = "Bearer $apiKey" }

$url = "https://console.automox.com/api/policies/$polid/action?o=MyOrgID"
$body = @"
  {
      "action": "remediateServer",
      "serverId": 12345
  }
"@

Invoke-WebRequest -Method POST -Uri $url -Headers $headers -Body $body
 

 

Invoke-WebRequest : The remote server returned an error: (400) Bad Request.

 

 

Badge

 

Anyone please ?

Userlevel 1

Hi,

I do not see the $apiKey variable being defined. Can you please add that and retry?

Hope this helps.

Reply