REST API to get computer IDs for group of systems

Hi,

can someone help me to get the computer IDs for group of systems. Right now I am able to get the computer ID for a single machine.

https://:52311/api/query?relevance=(ids of it) of bes computers whose (name of it as string as uppercase starts with “”)

I want to know the API query to get computer IDs for multiple system…

By ‘group of systems’, do you mean a Computer Group defined within BigFix?

If so, you could use session relevance such as the following in a call to /api/query:

ids of members of bes computer group whose (name of it as lowercase = "My Computer Group" as lowercase)

3 Likes

thanks for response Aram!!

Group of systems means multiple computers for e.g. computer1, computer2, computer3 so on…

how I can run a API query to get the Computer ID for multiple systems in one go.

So, assuming all you have is an arbitrary list of computer names, perhaps something like the following might work (there are likely more efficient methods, but this one is quick/easy if the lists are small):

ids of bes computers whose ("|computer1|computer2|computer3|" as lowercase contains ("|" & name of it as lowercase & "|"))

Thanks but did not work, below is the error message…

meanwhile I tried this but it is not efficient method I feel. I want to optimize this, can you please help

https://10.226.228.133:52311/api/query?relevance=(ids of it) of bes computers whose ((name of it as string as uppercase starts with “ACERTEST-PC”) or (name of it as string as uppercase starts with “15E-DTP-H-07882”)or (name of it as string as uppercase starts with “15A-DTP-H-02010”))

Note: here ACERTEST-PC, 15E-DTP-H-07882 & 15A-DTP-H-02010 are computer names

The error message This expression could not be parsed suggests a syntax error somewhere, often due to mismatching parens or double-quotes or similar (see Common Relevance Error Messages as reference). One way to help identify such issues is to test the relevance expression in the Presentation Debugger in the Console which might highlight the syntax issue: https://developer.bigfix.com/tools/presentation_debugger.html

You are casting the computer “as lowercase”, but then comparing to strings of mixed-case so none match. Convert your list to lowercase as well.

Hi Jason, tried with lowercase as well but same error message as above.

Hi Aram, let me check this update you back on this.

It may be an artifact of posting and displaying the image on here, but it doesn’t look as if you have included the whole of Aram’s relevance statement in your code.

Commenting on this a year later because search is useful. :grinning:

The clipping of the query is being caused by the ampersand. I’ve tried replacing it with & (for HTML) and & (for XML) but they both still clip the query. Taking out the “|”& and &"|" entirely works fine. How does one append text in a relevance query for the API?

How are you sending the query? If using curl or wget on the command line, it is likely the shell truncating the command line. While I would recommend learning Python (it’s not as bad as it sounds), the faster approach is probably to store your query ina text file and use the curl option to read the query from the file.

2 Likes

https://forum.bigfix.com/t/bes-properties-that-are-not-set-or-unkown-causing-relevance-query-issue/28061/10

Check that post, and the follow-ups after it, for another improvement on the method.

1 Like