REST API Delete Actions Older then, API REQUEST FAILED

I have a Powershell Script for delete actions from IEM with state Expired/Stop older then 30 days. The code paste below. The script is deleting actions like it should be but at some of IEM servers in our environment I received the error: “API Request FAiled: Cannot delete a child action”. Can I ignore this issue or is it making sth which can crash the server ??

[xml]$actions = .\iem get actions;
$count = $actions.BESAPI.Action.Count;
for ($i = 0; $i -lt $count; $i++) {
$id = $actions.BESAPI.Action[$i].ID;
Write-Progress -Activity “Deleting actions older than 30 days” -percentComplete ($i/$count*100)
[xml]$result = .\iem get action/$($id)/status;
if (@(“Expired”,“Stopped”) -contains $result.BESAPI.ActionResults.Status) {
[datetime]$actionDate = $result.BESAPI.ActionResults.DateIssued;
if ($actionDate -lt $lastMonth) {
./iem delete action/$($id) | Out-Null;
"./iem delete action/$id date_of_action: $($actionDate)" >> $log;
} #if check the action date
} #if check the status of action
} #for actions

1 Like

So I don’t use the BES CMD Line utility at all so all the following is an educated guess.

If you go into Web Reports and go to custom and type:

<?relevance (name of parent group of it | "None" , name of it) of bes actions ?>

What you’ll find is that when you make you select a bunch of fixlets, or you make a baseline and action them it actually creates an action for the group and then an action for every item of the group. This means if you have a baseline with ten items, and you action it, you end up with 11 actions.

The thing I think you’re running into is that when you have a baseline with ten fixlets in it, it makes eleven actions, you cannot delete or stop any of the child actions you can only delete the parent action it’s a part of (the action from the baseline or the group).

If you wanted to filter out child actions and only have actions that are the, “parent” you would use session relevance like this:

bes actions whose (not exists parent group of it)

As this will filter out every item with a parent, and leave you with only parents.

That being said, the errors you are seeing just means that it is skipping child actions. They will not cause any issues and will definitely not crash the server.

1 Like

Thank You for replay. I will try to modify the script to take only parent action into consideration. I am using PowerShell because we have about 40 IEM Servers and I would like to run the script from one of the IEM server and connect to rest of IEMS via API. But anyway, thank You for explain what can cause the monit about child actions.

The problem is solved. I first look for the Multiple Action parent by “BESAPI.ActionResults.MemberActionResult” and delete all parents actions. Then I delete rest of single actions. Thank You for the tip again.

1 Like


I too need the same script.
Can you please share me the full script.If I use this script I am getting error.

Please share me if you have full script.