Using REST API to query and take action

Hi All, so we use patch policy, and it creates actions. How can I use the BF API to query the action name (let’s say the name of the action is “PP_PatchInstall”) to get the action ID? I want to use the same action to take another action on a different target group using API. Can this be done?

Use the /query resource to send a session relevance query like ids of BES actions whose (name of it starts with "PP_PatchInstall") to get the action ID.

Then you’ll need to get /api/actions/actionid to retrieve the XML definition of the action, update to the new Target criteria you want, and then POST it back to /api/actions

1 Like

Thanks Jason. I’ll try that out today. Is there a way to grab the most recent action of that name? The action with the same name run every month and we want to make sure we get the most recent one.

How can I use the Action ID of an existing action in the XML to take another action?

  [xml]$body = @"
  <?xml version="1.0" encoding="UTF-8"?>
  <BES xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:noNamespaceSchemaLocation="BES.xsd">
  <SingleAction>
  <Sitename>Engineering</Sitename>

 <ActionID>90726</ActionID> ?? this doesn't work. 

 <Settings>
<HasTimeRange>false</HasTimeRange>
<HasStartTime>false</HasStartTime>
<HasEndTime>true</HasEndTime>
<EndDateTimeLocalOffset>P2D</EndDateTimeLocalOffset>
<PreActionCacheDownload>true</PreActionCacheDownload>
<ContinueOnErrors>true</ContinueOnErrors>
<PostActionBehavior Behavior="Nothing"/>
</Settings>
<Target>
<ComputerID>14370421</ComputerID>
</Target>
<StartDateTimeOffset>false</StartDateTimeOffset>
<EndDateTimeOffset>false</EndDateTimeOffset>
</SingleAction>
</BES>
"@

You can’t…you need to copy the XML into the new action directly. You cannot determine the ID of a new action you take, it just uses whatever the next unique identifier is.