BigFix API Query for fetching applications,publisher & versions details

Hi Everyone,

API Query:
Relevance:

https://<BigFix_Server>:52311/api/query?relevance=(
name of item 0 of it | “missing name”
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 1 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 2 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 3 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 4 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 5 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 6 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 7 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 8 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 9 of it))
& “||” & (concatenation “;” of values of results (item 0 of it, elements of item 10 of it))
) of (
elements of item 0 of it
,item 1 of it
,item 2 of it
,item 3 of it
,item 4 of it
,item 5 of it
,item 6 of it
,item 7 of it
,item 8 of it
,item 9 of it
,item 10 of it
) of (
set of BES computers
, set of bes properties whose (name of it as lowercase = (“Computer ID”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“IP Address”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“Computer Name”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“Computer Manufacturer - Windows”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“Computer Model - Windows”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“CPU”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“CPU Name”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“MAC Address”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“Make”) as lowercase)
, set of bes properties whose (name of it as lowercase = (“Applications_Installed_Workstations”) as lowercase)
)

Customized:
Analysis name:
Applications_Installed_Workstations
Relevance:

unique values of (value "DisplayName" of it as string & "," & (value "Publisher" of it as string | "Unknown Publisher") & "," & (value "DisplayVersion" of it as string | value "Version" of it as string | "N/A")) of keys whose (exists value "DisplayName" of it) of keys "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registries; x64 registries)

Output:
7-Zip 25.01 (x64 edition),Igor Pavlov,25.01.00.0
WinSCP 6.5.3,Martin Prikryl,6.5.3
Microsoft Visual C++ 2008 Redistributable - x64 9.0.30729.6161,Microsoft Corporation,9.0.30729.6161
Microsoft Visual C++ 2008 Redistributable - x86 9.0.30729.6161,Microsoft Corporation,9.0.30729.6161

The output will be line by line.

Someone please helps me out, how I can get all these details via Api?
@jgstew

which part is not working? It looks like you've got it already.

If I’m not mistaken, you’re interested in results on a per-line, per-app basis rather than for the whole block. Please try the following:

(
(name of item 0 of item 0 of it | "missing name")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 1 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 1 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 2 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 2 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 3 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 3 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 4 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 4 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 5 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 5 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 6 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 6 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 7 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 7 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 8 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 8 of item 0 of it)
else "N/A")
& "||" & (if exists values of results (item 0 of item 0 of it, elements of item 9 of item 0 of it)
then concatenation ";" of values of results (item 0 of item 0 of it, elements of item 9 of item 0 of it)
else "N/A")
& "||" & (item 1 of it as trimmed string) /* app entry OR "N/A" */
)
of
(
(it,
substrings separated by ";"
of (
if exists values of results (item 0 of it, elements of item 10 of it)
then concatenation ";" of values of results (item 0 of it, elements of item 10 of it)
else "N/A"
)
)
of
(
elements of item 0 of it,
item 1 of it,
item 2 of it,
item 3 of it,
item 4 of it,
item 5 of it,
item 6 of it,
item 7 of it,
item 8 of it,
item 9 of it,
item 10 of it
)
of
(
set of BES computers,
set of bes properties whose (name of it as lowercase = ("Computer ID") as lowercase),
set of bes properties whose (name of it as lowercase = ("IP Address") as lowercase),
set of bes properties whose (name of it as lowercase = ("Computer Name") as lowercase),
set of bes properties whose (name of it as lowercase = ("Computer Manufacturer - Windows") as lowercase),
set of bes properties whose (name of it as lowercase = ("Computer Model - Windows") as lowercase),
set of bes properties whose (name of it as lowercase = ("CPU") as lowercase),
set of bes properties whose (name of it as lowercase = ("CPU Name") as lowercase),
set of bes properties whose (name of it as lowercase = ("MAC Address") as lowercase),
set of bes properties whose (name of it as lowercase = ("Make") as lowercase),
set of bes properties whose (name of it as lowercase = ("Applications_Installed_Workstations") as lowercase)
)
)
whose (item 1 of it != "")

Expected Results:
A: VKMINI||N/A||192.168.68.109;192.168.182.1;192.168.79.1||VKMINI||N/A||N/A||3300 MHz Ryzen 9 6900HX with Radeon Graphics ||N/A||00-50-8b-6a||Default string||7-Zip 23.01 (x64 edition),Igoov,23.01.00.0
A: VKMINI||N/A||192.168.68.109;192.168.182.1;192.168.79.1||VKMINI||N/A||N/A||3300 MHz Ryzen 9 6900HX with Radeon Graphics ||N/A||00-50-56-1-8b-6a||Default string||Azure Data Studio,Microsoft Corporation,1.44.0

Note: If you have N apps, you’ll get N lines that are mostly identical; only the last part will differ based on each app’s results.

Also added N/A logic if no app found:
A: UNKNOWN-U0T3FD5||N/A||192.168.79.130||UNKNOWN-U0T3FD5||N/A||N/A||3300 MHz Ryzen 9 6900HX with Radeon Graphics ||N/A||00-50-1-33-0a||VMware, Inc.||N/A

Hi @JasonWalker
I can’t get the results of “Applications_Installed_Workstations”. it’s not showing any results in the Api query.

Hi @vk.khurava

It’s showing Requested resource does not exist.

Buddy, as I mentioned in your earlier post on a similar question, you need to apply URL encoding before calling the URL-based API query. Try the example below, it’s built exactly from your inputs and matches the RP names one-to-one:

BigFix Rest API session relevance query - Content Authoring - BigFix Forum

https://<YOUR_BIGFIX_SERVER>:52311/api/query?relevance=((%20%20%20(name%20of%20item%200%20of%20item%200%20of%20it%20|%20"missing%20name")%20%20%20%26%20"||"%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%201%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20"%3B"%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%201%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20"N%2FA"``)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%202%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%202%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%203%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%203%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%204%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%204%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%205%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%205%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%206%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%206%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%207%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%207%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%208%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%208%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(if%20exists%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%209%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20item%200%20of%20it%2C%20elements%20of%20item%209%20of%20item%200%20of%20it)%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22)%20%20%20%26%20%22%7C%7C%22%20%26%20(item%201%20of%20it%20as%20trimmed%20string)%20%20%20%2F*%20app%20entry%20OR%20%22N%2FA%22%20*%2F%20)%20of%20(%20%20%20(it%2C%20%20%20%20substrings%20separated%20by%20%22%3B%22%20%20%20%20%20%20of%20(%20%20%20%20%20%20%20%20%20%20%20if%20exists%20values%20of%20results%20(item%200%20of%20it%2C%20elements%20of%20item%2010%20of%20it)%20%20%20%20%20%20%20%20%20%20%20then%20concatenation%20%22%3B%22%20of%20values%20of%20results%20(item%200%20of%20it%2C%20elements%20of%20item%2010%20of%20it)%20%20%20%20%20%20%20%20%20%20%20else%20%22N%2FA%22%20%20%20%20%20%20%20%20%20)%20%20%20)%20%20%20of%20%20%20(%20%20%20%20%20elements%20of%20item%200%20of%20it%2C%20%20%20%20%20item%201%20of%20it%2C%20%20%20%20%20item%202%20of%20it%2C%20%20%20%20%20item%203%20of%20it%2C%20%20%20%20%20item%204%20of%20it%2C%20%20%20%20%20item%205%20of%20it%2C%20%20%20%20%20item%206%20of%20it%2C%20%20%20%20%20item%207%20of%20it%2C%20%20%20%20%20item%208%20of%20it%2C%20%20%20%20%20item%209%20of%20it%2C%20%20%20%20%20item%2010%20of%20it%20%20%20)%20%20%20of%20%20%20(%20%20%20%20%20set%20of%20BES%20computers%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22Computer%20ID%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22IP%20Address%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22Computer%20Name%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22Computer%20Manufacturer%20-%20Windows%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22Computer%20Model%20-%20Windows%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22CPU%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22CPU%20Name%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22MAC%20Address%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22Make%22)%20as%20lowercase)%2C%20%20%20%20%20set%20of%20bes%20properties%20whose%20(name%20of%20it%20as%20lowercase%20%3D%20(%22Applications_Installed_Workstations%22)%20as%20lowercase)%20%20%20)%20)%20whose%20(item%201%20of%20it%20!%3D%20%22%22))

Query Results:

1 Like

It looks like there are several moving parts in your setup that may not be working correctly. I’d recommend first focusing on getting the RP results fixed, and then building your API query against a single, known-good item to confirm you’re getting the expected output.

I simply used your logic below, created an RP with it, and was able to successfully retrieve the results, both directly from the RP and via a single API query, as well as with the combined approach I shared in my previous post.

If you’re still unable to obtain the expected results, it may be helpful to work with your local BigFix administrator or someone who can review each broken piece with you in your environment. From our side, using the inputs you’ve provided, we’re able to generate the desired results, so the next step is to troubleshoot each item individually on your setup.

2 Likes

@SATHISH, to test your snipped code quickly, use Presentation Debugger https://developer.bigfix.com/tools/presentation_debugger.html