RESTAPI : Import Action (from BASELINE) to Target Computergroup

Hello all.

I created via a scheduled job a xml file containing MultiactionGroup. It’s the same principle as the creation of a baseline with RESTAPI.
I just change some parameter in the head-on.

wait curl -k --data-urlencode relevance="concatenations %22%22 of (%22< MemberAction>< Title>%2522%22 & ( concatenation %22%26amp; %22 of substrings separated by %22%26 %22 of item 0 of it) & %22%2522< /Title>< Relevance>%22 & item 9 of it & %22< /Relevance>< ActionScript MIMEType=%2522%22 & item 5 of it & %22%2522>%22 & item 6 of it & %22< /ActionScript>< SuccessCriteria Option=%2522%22 & item 7 of it & %22%2522>%22 & item 8 of it & %22< /SuccessCriteria>< /MemberAction>%22) of ( (if (it contains %22%2522%22) then (concatenations %22%26quot;%22 of substrings separated by %22%2522%22 of it) else it) of name of it, (it as string as lowercase) of (not success on run to completion of default action of it), url of site of it, (it as string) of id of it, content id of default action of it, script type of default action of it, (%22<![CDATA[%22 & it & %22%5d%5d>%22) of script of default action of it, (if (success on custom relevance of it) then %22CustomRelevance%22 else if (success on original relevance of it) then %22OriginalRelevance%22 else if (success on run to completion of it) then %22RunToCompletion%22 else %22%22) of default action of it, (if (not success on custom relevance of it) then %22%22 else (%22<![CDATA[%22 & it & %22%5d%5d>%22) of (custom success relevance of it)) of default action of it, (%22<![CDATA[%22 & it & %22%5d%5d>%22) of relevance of it) of fixlets whose(exists source release dates of it AND ( (0 < applicable computer count of it) ) AND exists default action of it AND fixlet flag of it AND globally visible flag of it AND name of it does not contain %22(Superseded)%22 AND source severity of it is %22Critical%22 ) of bes sites whose(name of it contains %22Patches for RHEL%22)" -o "{pathname of download folder}/BaselineComponents-ActionCritic.xml" --user IEMAdmin:XXXXX  https://{parameter "RootServerURL"}/api/query

After i adding header and I generate a file .bes, that I can import it manually.

createfile until END_OF_FILE
<?xml version="1.0" encoding="UTF-8"?>
< BES xmlns:xsi="" xsi:noNamespaceSchemaLocation="BES.xsd">
    < MultipleActionGroup>
        < Title>Weekly Patches - 26 May 2016 - All OS RHEL Important and Critical Fix </Title>
        < Relevance>true</Relevance>
            **{node value of xpath "/BESAPI/Query/Result/Answer/text()" of xml document of file "BaselineComponents-ActionCritic.xml" of download folder}**
        < Settings>
        < /SettingsLocks>
    < /MultipleActionGroup>
< /BES>

move __createfile __Download/Action-W1D1H1.bes

Everything works well. :grin:

I import the created .bes file with /api/actions like :

curl -k -X POST --data-binary @Action-W1D1H1.bes --user IEMAdmin:XXXXXX https://MY_SERVER:52311/api/actions

But before i need to choose target.
If I inserts

 < Target>
                        < ComputerID>8619658</ComputerID>
< /Target>


< Target>
  < ComputerName>ltstni8t< /ComputerName>
  < /Target>

all is work fine…

BUT… i would like insert a ComputerGroup :rage: and then nothing works …

i listed all my computergroups with
curl -k --user IEMAdmin:XXXXX https://SERVER:52311/api/computergroups/custom/PTEC3o30

 < ComputerGroup Resource="https://SERVER:52311/api/computergroup/custom/PTEC3o30/16777238" LastModified="Mon, 30 May 2016 08:35:06 +0000">
                < Name>[3o30]_WKIT_Group_W1D1H1</Name>
                < ID>16777238</ID>
        < /ComputerGroup>

I can’t arrive to find wath is the good keyword to insert a COMPUTERGROUP to a < /MultipleActionGroup> behin < Target>

Could you help me ?

The next step it’s to try with

< Target>
< CustomRelevance>(member of group 16777239 of site "PTEC3o30") < /CustomRelevance>
< /Target>
< /MultipleActionGroup>

But no computers take my action… :frowning:
What is the syntax to entre SiteName ??? PTEC3o30 or custom/PTEC3o30

For information it’s an automaticgroup based on a value from a property.

Best Regards

1 Like

This is the right approach – assuming that is the right id of the computer group. Maybe try just:

member of group 16777239 of sites

What site are you adding this action to? The computers must be subscribed to the site the action exists in so if you’re using the API to push the action – all of the computers in question must be subscribed to the operator account you are using the API from.

1 Like

If it’s a Custom Site, the site name is prefixed by “CustomSite_”. For instance in my console I have a custom site that appears as “CM_Windows”; when I use the API to target an action by group in the site, I use
<Target> <CustomRelevance>member of group 16838034 of site "CustomSite_CM_Windows"</CustomRelevance> </Target>

…the format for the site can be retrieved via the “tag” property -

(name of it, tag of it) of bes custom sites
CM_Linux, CustomSite_CM_Linux
CM_Windows, CustomSite_CM_Windows
Content_Downloads_Temporary, CustomSite_Content_Downloads_Temporary
1 Like

You can’t target a computer group directly, and must instead use custom relevance, which you did arrive at doing. Not even the console actually uses a computer group directly. When you choose a computer group in the console, it generates some relevance on the fly.

When you target something to a computer group using the REST API, it doesn’t show up in the console in the same nice way as it does when you do the same through the console. :frowning:

I even tried using the exact same relevance that the console generates when it targets groups, and that didn’t work either. :frowning:

I do something similar to this. See here:

exists members whose(it = TRUE) of ( groups /* GroupName1 */ 123 of it; groups /* GroupName2 */ 1234 of it; groups /* GroupName3 */ 12345 of it ) of sites

You can use this session relevance to generate this dynamically:

Side note: @Nicolas - don’t put weird spaces in your XML to get it to show up in the forum properly. Instead put 4 spaces at the beginning of each line by highlight the code and clicking the </> button.

1 Like