Wrapping individual members of bes computer groups in double quote

The below query provides the endpoints as desired but in using the output to perform an automation with another application, to satisfy that app’s syntax, we need to wrap the members in double quotes. I can’t seem to get the syntax correct to add the double quotes before the first and after the last member of the group.

https://bigfix:52311/api/query?relevance=((name of it, id of it, concatenation "%252522, %252522" of names of members of it) of bes computer groups whose (name of it = "GROUP"))

<BESAPI xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="((name of it, id of it, concatenation "%22, %22" of names of members of it) of bes computer groups whose (name of it = "GROUP"))">
<Result>
<Tuple>
<Answer type="string">GROUP</Answer>
<Answer type="integer">1108677</Answer>
<Answer type="string">
MEMBER01", "MEMBER02", "MEMBER02", "MEMBER03", "MEMBER04
</Answer>
</Tuple>
</Result>
<Evaluation>
<Time>4.975ms</Time>
<Plurality>Plural</Plurality>
</Evaluation>
</Query>
</BESAPI>

Hoping for someone to shine a light into the correct corner of the documentation or another post that covers this if possible?

Try
("%252522" & it & "%252522") of concatenation ", " of names of members of it

Thanks Jason,

This is almost there. It took me a bit to get back to this and I can get the code to work if the double quotes are around the entire CSV list of members:
"MEMBER01, MEMBER02, MEMBER02, MEMBER03, MEMBER04"

but not with the double quotes around each individual member of the CSV list. eg:
"MEMBER01", "MEMBER02", "MEMBER02", "MEMBER03", "MEMBER04"

When I use this query:

(name of it, id of it, ("%252522" & it & "%252522") of concatenation "%252522, %252522" of names of members of it) of bes computer groups whose (name of it = "GROUP")

In the Presentation Debugger it seems to works with a result like:

GROUP, 1108677, ( %2522MEMBER1%2522, %2522MEMBER2%2522, %2522MEMBER3%2522, %2522MEMBER4%2522 )

When I try that same query in the API via browser it returns an error:

<BESAPI xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of it, id of it, ("%22" ">
<Result/>
<Error>This expression could not be parsed.</Error>
</Query>
</BESAPI>

For me it seems quotes inside quotes inside brackets etc is always problematic at the command line, adding the URL encoding is not helping! Is the issue obvious to a different set of eyes?

See how the ‘Query’ Resource is truncated at the ampersand & symbol? That’s likely from your she’ll cutting that off of a curl command.

Assuming you are sending this with curl, check this link for better options on sending the query - and you don’t even have to url-encode, curl can do that for you!

Thanks for your help on this one Jason.

In the end, the easiest solution was not the custom relevance code to generate the double quotes, it was to use json output with a different type of API call since json strings are wrapped in quotes by default. :roll_eyes:

https://bigfix:52311/api/query?relevance=(names of members of bes computer groups whose (name of it = "GROUP"))&output=json

Provides the output we needed:

{"result":["MEMBER1","MEMBER2","MEMBER3","MEMBER4","MEMBER5"],"plural":true,"type":"string","evaltime_ms":4}

I needed to be able to provide an example that non-BigFix aware admins could reuse to obtain endpoint lists from BigFix and the other path was not ideal “beginner code”. We do still validate the name and obtain the ID as well but internal API calls are cheap so we can always make more than one.

1 Like