Session relevance query for computers properties snapshot

How do I use /api/query REST api to get results for all computers in format similar to whats below Without knowing the property names in advance:>

<Computer>
<ID>181</ID>
<Name>myHost</Name>
<Installed Applications>
<Name>xyz</Name><Version>1.2.1</Version>
</InstalledApplications>
</Computer>
<Computer>
<ID>230</ID>
<Name>otherHost</Name>
<InstalledApplications>
<Name>xyz</Name><Version>1.2.2</Version>
</InstalledApplications>
</Computer>

I don’t believe you can get the xml output like that by default when using api/query?relevance=. When using api/query?relevance= you’ll get something like this depending on the query.

<Tuple>
    <Answer type="integer">123456</Answer>
    <Answer type="string">COMPUTER NAME</Answer>
</Tuple>

However you can return json instead of xml, which I find easier to work with for queries.

api/query?output=json&relevance="(some query)"

which returns something like:

 {"result": [
    [123456, COMPUTER NAME], 
    [256789, COMPUTER NAME],
    ]}
1 Like

Ok, perhaps I did not phrase my question right. The response can be any form, XML/JSON/ any other
What I need is to pull all properties associated with computers (including custom/analyse properties) without actually querying for bes properties by name.
This is what i need
{“result”: [
{id: 123456,name: COMPUTERNAME, property1Name: property1Value(s), …},
{id: 123456,name: COMPUTERNAME, property1Name: property1Value(s), …},
…
]}
Purpose: I need to dump the bigfix computer properties snapshots (all that you can see for a computer in the console) in a DB periodically.
Any suggestions? Can this be done using relevance query?

Hello sanyampandey,

Please try the following session relevance:

((names of it, (if analysis flag of it=True then name of source analysis of it else "global")) of properties of it, values of it) of property results of (bes computers whose (name of it as lowercase = "computername"))

Regards,
Vitaliy

I want to get snapshot in a single relevance query call for all computers at once. The result expected is either XML/JSON such that I can easily access all properties of computers
For e.g.
Computer 1 => [ array of key value pairs for all its properties]
Computer 2 => [array of key value pairs for all its properties]

What I do NOT want is 1) making multiple queries. 2) result in form where properties are not grouped by computer ids

Thanks,
Sanyam

Well, that’s the closest I’ve got:

https://<hostname>:<port>/api/query?output=json&relevance=((id of it), ((names of properties of it, values of it) of property results of it)) of bes computers

It does not have exact data structure you want: it has a computer ID together with each pair property name/value:

{"result":[
[4317046,["Computer Name","computername1"]],
[4317046,["OS","Win10 10.0.17134"]],
...
[5171199,["Computer Name","computername2"]],
[5171199,["OS","Win2012R2 6.3.9600"]],
...

Regards,
Vitaliy

I am using something similar. Even though the result is always sorted by computer ids, I was hoping for something that a xml or json parser could parse. Doesn’t seem to be possible at the moment. I shall continue using this and do line by line processing of the response to accumulate all properties for computers. Thanks.