help with API with "issue a command to a device

Hi All,

want to see what I’m doing wrong here… trying to follow the example here https://docs.automox.com/api/endpoints/issue-a-command-to-a-device#example-requests, to issue a command to a server so it can remediate itself, I want to do it one server at a time so it doesn’t take everyone down at once… I’m trying to use the command type “policy_{policy_id}_remediate”

so here is how I’m calling it through curl

curl -X POST
https://console.automox.com/api/servers/{server_id}/queues?o={org_id}
-H ‘Authorization: Bearer {api_key}’
-H ‘Content-Type: application/json’
-d '{
“command_type_name”: “policy_{policy_id}_remediate”

}’

I keep getting a {“errors”:[“The selected command type name is invalid.”]} error message…

am I calling it right? or is that for something else?

thanks,
Alan

Probably a dumb question, but sanity check here – we are substituting all the bracketed strings for actual values, right?

yes, if I do other command type such as “InstallAllUpdates” its coming back fine.

I was able to replicate your issue, getting a (400) bad request when attempting to use policy_{policy_id}_remediate as the docs state. GetOS returns a correct query, so something syntax related must be amiss in the docs. However, as a workaround, there is another query to accomplish your goal using https://docs.automox.com/api/policies/start-policy-for-immediate-remediation

Here is a script that I use in our environment from @Tony

1 Like

thank you so much Matt, that works!

1 Like