I’ve tried every possible connotation I can think of but still can’t get this to work
I need an API call - most likely using WebReports Query - to find out which Baseline Components are relevant to an endpoint.
The components can be part of any baseline with the name starting with “RHEL8” and from a custom site names “RHEL8”
I’m kind of somewhere around this at the moment but keep failing no matter what I try
<Query Resource=“(id of source fixlet of it, name of site of source fixlet of it) of components whose (exists elements whose (name of it as lowercase contains “RH” as lowercase) of applicable computer set of it) of component groups of bes baselines whose (display name of site of it = “RHEL8”)”>
The API call will specify a single endpoint and for that endpoint I want to see a list of Baseline Components that are relevant for it from the Custom Site “RHEL8” and where the baseline name starts with “RHEL8”
There are going to be multiple baselines in that custom site that start with RHEL8 so I need it to look through all of them and only return the components that are relevant
(names of item 1 of it, names of item 0 of it, relevant (item 0 of it, item 1 of it)) of (source fixlets of components of component groups of relevant fixlets whose (baseline flag of it AND name of it starts with “RHEL8” AND custom site flag of it AND display name of custom site of it starts with “RHEL8”) of bes computers whose (id of it = 1303991),bes computers whose (id of it = 1303991))
(if (item 2 of it) then (item 0 of it, item 1 of it) else nothing) of (names of item 1 of it, names of item 0 of it, relevant (item 0 of it, item 1 of it) ) of (source fixlets of components of component groups of relevant fixlets whose (baseline flag of it AND name of it starts with “RHEL8 ” AND custom site flag of it AND display name of custom site of it starts with “RHEL8 ”) of bes computers whose (id of it = 1303991 ),bes computers whose (id of it = 1303991 ))
(if (item 2 of it) then (item 3 of it, item 1 of it, item 0 of it) else nothing) of (name of item 0 of it, name of item 1 of it, relevant (item 1 of it, item 2 of it), name of item 2 of it) of (item 0 of it,source fixlets of components of component groups of item 0 of it,item 1 of it) of (relevant fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 ") of bes computers whose (id of it = 1303991 ),bes computers whose (id of it = 1303991 ))
This will return the Following results:
LAB-ORB, FIXLET - Return TRUE, RHEL8 - Baseline 1
LAB-ORB, FIXLET - Return TRUE, RHEL8 - Baseline 2
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(if (item 2 of it) then (item 3 of it, item 1 of it, item 0 of it) else nothing) of (name of item 0 of it, name of item 1 of it, relevant (item 1 of it, item 2 of it), name of item 2 of it) of (item 0 of it,source fixlets of components of component groups of item 0 of it,item 1 of it) of (relevant fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 ") of bes computers whose (id of it = 2697954647),bes computers whose (id of it = 2697954647))">
<Result/>
<Evaluation>
<Time>47.193ms</Time>
<Plurality>Plural</Plurality>
</Evaluation>
</Query>
</BESAPI>
I would personally write it with sets - looks a bit uglier at first but it would scale to any size of machines & components/baselines. Also, worth noting it does matter on the API account permissions. If for example, baseline or any of the components are “globally hidden” and user essentially is NMO then they won’t be able to see them ; same with the site permissions; machine permissions; etc (can’t bypass the permission limitations is the bottom line).
(name of item 0 of it|"Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of ((set of source fixlets of components of component groups of item 1 of it); relevant fixlet set of item 0 of it)) else (nothing)) of (item 0 of it, elements of item 1 of it)) of (elements of item 0 of it, item 1 of it) of (set of bes computers whose (id of it = 2697954647), set of bes fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 "))
.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of item 0 of it|"Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of ((set of source fixlets of components of component groups of item 1 of it)">
<Result/>
<Error>This expression could not be parsed.</Error>
</Query>
</BESAPI>
I get this now
but I also tried
(name of item 0 of it | "Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of (set of source fixlets of components of component groups of item 1 of it, relevant fixlet set of item 0 of it)) else (nothing)) of (item 0 of it, elements of item 1 of it)) of (elements of item 0 of it, item 1 of it) of (set of bes computers whose (id of it = 2697954647), set of bes fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 "))
You need to uri-encode the relevance first, mate. Some of the special characters when you post them as an API call are not automatically escaped by the APi service. Pretty much any programming language would have uri-encode/decode function but if you are looking for something quick with interface, I use this website. You give it the relevance, it gives you the encoded version of it and you plug that into the call.
The ‘Query’ field there looks like it was truncated, either by a copy/paste issue or by the tool you’re using to send the query. If you’re using a browser you need to URL-encode the query itself first. If you’re using Python or PowerShell it likely url-encodes it for you. If you’re using curl you may need to specify on the command line.
I encoded it and I’m using the browser but still seem to get an error
<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of item 0 of it|"Missing Name", (if (relevant (item 0 of it, item 1 of it)) then (name of item 1 of it, names of elements of intersection of ((set of source fixlets of components of component groups of item 1 of it); relevant fixlet set of item 0 of it)) else (nothing)) of (item 0 of it, elements of item 1 of it)) of (elements of item 0 of it, item 1 of it) of (set of bes computers whose (id of it = 2697954647), set of bes fixlets whose (baseline flag of it AND name of it starts with "RHEL8 " AND custom site flag of it AND display name of custom site of it starts with "RHEL8 "))">
<Result/>
<Evaluation>
<Time>51.844ms</Time>
<Plurality>Plural</Plurality>
</Evaluation>
</Query>
</BESAPI>
Did you check this bit? Have you confirmed your API account has permissions to the site/device and none of the stuff is “globally hidden”, unless the account itself is MO… In fact, any chance you can test it with MO API account (that should rule out permissions)?
Hm. There’s something very weird happening here because that result you’re showing isn’t even valid XML. The <Query Resource= is an attribute so the whole query should be wrapped in quotes; but the double quotes you had as part of the original query should have been XML-escaped as " instead of being shown literally.
Can you post a copy of the actual thing you’re putting in the browser bar (replace your server name), and what version of BigFix are you using?
That’s not it then. I would look at Jason’s thing. How are you posting the API query? Is it via a browser? Try a different tool for example - try powershell (can share a snippet of code to both encode & post if you’d like); if you prefer something with UI, I use Postman occasionally and it is quite good.