Use the REST API to return 25 properties in JSON format

Hello,

I would like to use the REST API to pull 25 assorted properties and output the results in json format. Twice a day our cmdb would query the rest api. Can I use the property names assuming they are unique or should I use the property ID. An example would be helpful.

We can certainly provide examples, but a question before that if I may: which CMDB would you like to integrate with here?

It can certainly make a difference which CMDB you are going to use. But for the pure problem of “querying properties in Session Relevance”, definitely have a read-through of this repost of @brolly33’s blog on the topic, where he addresses querying property results efficiently at scale, handling properties that do not exist, have no results, or have duplicate names, at Efficient Session Relevance Query for Computer Properties

4 Likes

Agreed.

@brolly33’s blog/approach is still my go to here :slight_smile:

2 Likes

Hello The CMDB is based on JIRA service desk, does that help

Thank you, I asked to better understand more about integrations of interest.

Regarding an example, here’s one based on @brolly33’s efficient syntax and structure that was built using the client-relevance method:

(
id of item 0 of it as string | "missing id"
& "{=}" & (if (size of item 1 of it = 1) then ((if it = "" then "Property 1: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 1 of it)) else (if (size of item 1 of it > 1) then (("Property 1 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 1 of it) as string) else ("Property 1 does not exist")))
& "{=}" & (if (size of item 2 of it = 1) then ((if it = "" then "Property 2: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 2 of it)) else (if (size of item 2 of it > 1) then (("Property 2 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 2 of it) as string) else ("Property 2 does not exist")))
& "{=}" & (if (size of item 3 of it = 1) then ((if it = "" then "Property 3: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 3 of it)) else (if (size of item 3 of it > 1) then (("Property 3 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 3 of it) as string) else ("Property 3 does not exist")))
& "{=}" & (if (size of item 4 of it = 1) then ((if it = "" then "Property 4: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 4 of it)) else (if (size of item 4 of it > 1) then (("Property 4 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 4 of it) as string) else ("Property 4 does not exist")))
& "{=}" & (if (size of item 5 of it = 1) then ((if it = "" then "Property 5: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 5 of it)) else (if (size of item 5 of it > 1) then (("Property 5 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 5 of it) as string) else ("Property 5 does not exist")))
& "{=}" & (if (size of item 6 of it = 1) then ((if it = "" then "Property 6: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 6 of it)) else (if (size of item 6 of it > 1) then (("Property 6 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 6 of it) as string) else ("Property 6 does not exist")))
& "{=}" & (if (size of item 7 of it = 1) then ((if it = "" then "Property 7: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 7 of it)) else (if (size of item 7 of it > 1) then (("Property 7 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 7 of it) as string) else ("Property 7 does not exist")))
& "{=}" & (if (size of item 8 of it = 1) then ((if it = "" then "Property 8: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 8 of it)) else (if (size of item 8 of it > 1) then (("Property 8 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 8 of it) as string) else ("Property 8 does not exist")))
& "{=}" & (if (size of item 9 of it = 1) then ((if it = "" then "Property 9: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 9 of it)) else (if (size of item 9 of it > 1) then (("Property 9 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 9 of it) as string) else ("Property 9 does not exist")))
& "{=}" & (if (size of item 10 of it = 1) then ((if it = "" then "Property 10: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 10 of it)) else (if (size of item 10 of it > 1) then (("Property 10 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 10 of it) as string) else ("Property 10 does not exist")))
& "{=}" & (if (size of item 11 of it = 1) then ((if it = "" then "Property 11: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 11 of it)) else (if (size of item 11 of it > 1) then (("Property 11 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 11 of it) as string) else ("Property 11 does not exist")))
& "{=}" & (if (size of item 12 of it = 1) then ((if it = "" then "Property 12: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 12 of it)) else (if (size of item 12 of it > 1) then (("Property 12 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 12 of it) as string) else ("Property 12 does not exist")))
& "{=}" & (if (size of item 13 of it = 1) then ((if it = "" then "Property 13: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 13 of it)) else (if (size of item 13 of it > 1) then (("Property 13 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 13 of it) as string) else ("Property 13 does not exist")))
& "{=}" & (if (size of item 14 of it = 1) then ((if it = "" then "Property 14: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 14 of it)) else (if (size of item 14 of it > 1) then (("Property 14 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 14 of it) as string) else ("Property 14 does not exist")))
& "{=}" & (if (size of item 15 of it = 1) then ((if it = "" then "Property 15: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 15 of it)) else (if (size of item 15 of it > 1) then (("Property 15 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 15 of it) as string) else ("Property 15 does not exist")))
& "{=}" & (if (size of item 16 of it = 1) then ((if it = "" then "Property 16: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 16 of it)) else (if (size of item 16 of it > 1) then (("Property 16 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 16 of it) as string) else ("Property 16 does not exist")))
& "{=}" & (if (size of item 17 of it = 1) then ((if it = "" then "Property 17: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 17 of it)) else (if (size of item 17 of it > 1) then (("Property 17 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 17 of it) as string) else ("Property 17 does not exist")))
& "{=}" & (if (size of item 18 of it = 1) then ((if it = "" then "Property 18: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 18 of it)) else (if (size of item 18 of it > 1) then (("Property 18 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 18 of it) as string) else ("Property 18 does not exist")))
& "{=}" & (if (size of item 19 of it = 1) then ((if it = "" then "Property 19: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 19 of it)) else (if (size of item 19 of it > 1) then (("Property 19 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 19 of it) as string) else ("Property 19 does not exist")))
& "{=}" & (if (size of item 20 of it = 1) then ((if it = "" then "Property 20: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 20 of it)) else (if (size of item 20 of it > 1) then (("Property 20 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 20 of it) as string) else ("Property 20 does not exist")))
& "{=}" & (if (size of item 21 of it = 1) then ((if it = "" then "Property 21: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 21 of it)) else (if (size of item 21 of it > 1) then (("Property 21 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 21 of it) as string) else ("Property 21 does not exist")))
& "{=}" & (if (size of item 22 of it = 1) then ((if it = "" then "Property 22: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 22 of it)) else (if (size of item 22 of it > 1) then (("Property 22 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 22 of it) as string) else ("Property 22 does not exist")))
& "{=}" & (if (size of item 23 of it = 1) then ((if it = "" then "Property 23: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 23 of it)) else (if (size of item 23 of it > 1) then (("Property 23 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 23 of it) as string) else ("Property 23 does not exist")))
& "{=}" & (if (size of item 24 of it = 1) then ((if it = "" then "Property 24: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 24 of it)) else (if (size of item 24 of it > 1) then (("Property 24 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 24 of it) as string) else ("Property 24 does not exist")))
& "{=}" & (if (size of item 25 of it = 1) then ((if it = "" then "Property 25: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 25 of it)) else (if (size of item 25 of it > 1) then (("Property 25 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 25 of it) as string) else ("Property 25 does not exist")))
& "{=}" & (if (size of item 26 of it = 1) then ((if it = "" then "Property 26: No values" else it) of concatenation "{|}" of values of results (item 0 of it, elements of item 26 of it)) else (if (size of item 26 of it > 1) then (("Property 26 duplicates: " & concatenation "|" of ((name of it) & "=" & (id of it as string)) of elements of item 26 of it) as string) else ("Property 26 does not exist")))
) 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
,item 11 of it
,item 12 of it
,item 13 of it
,item 14 of it
,item 15 of it
,item 16 of it
,item 17 of it
,item 18 of it
,item 19 of it
,item 20 of it
,item 21 of it
,item 22 of it
,item 23 of it
,item 24 of it
,item 25 of it
,item 26 of it
) of (
set of BES computers
, set of bes properties whose (id of it = (2147486054, 12, 1))
, set of bes properties whose (id of it = (2147486054, 13, 1))
, set of bes properties whose (id of it = (2147486054, 14, 1))
, set of bes properties whose (id of it = (2147486054, 15, 1))
, set of bes properties whose (id of it = (2147486054, 16, 1))
, set of bes properties whose (id of it = (2147486054, 17, 1))
, set of bes properties whose (id of it = (2147486054, 18, 1))
, set of bes properties whose (id of it = (2147486054, 19, 1))
, set of bes properties whose (id of it = (2147486054, 20, 1))
, set of bes properties whose (id of it = (2147486054, 21, 1))
, set of bes properties whose (id of it = (2147486054, 22, 1))
, set of bes properties whose (id of it = (2147486054, 23, 1))
, set of bes properties whose (id of it = (2147486054, 24, 1))
, set of bes properties whose (id of it = (2147486054, 25, 1))
, set of bes properties whose (id of it = (2147486054, 26, 1))
, set of bes properties whose (id of it = (2147486054, 27, 1))
, set of bes properties whose (id of it = (2147486054, 28, 1))
, set of bes properties whose (id of it = (2147486054, 1307, 1))
, set of bes properties whose (id of it = (2147486054, 5415, 1))
, set of bes properties whose (id of it = (2147486054, 5416, 1))
, set of bes properties whose (id of it = (2147486054, 6793, 1))
, set of bes properties whose (id of it = (2147486054, 6794, 1))
, set of bes properties whose (id of it = (2147486054, 6795, 1))
, set of bes properties whose (id of it = (2147486054, 23585, 1))
, set of bes properties whose (id of it = (2147486054, 23586, 1))
, set of bes properties whose (id of it = (2147486054, 78829, 1))
)
1 Like

Wow, Thank you very much. But gosh my eyes hurt trying to read that. Oh my. So a follow-up question, is broll33’s method more or less efficient than using the client relevance method. BTW that for creating that tool. BigFix needs more tools. Again thank you for your time.

The client relevance I referenced is really just a way to generate session relevance based on brolly33’s method rather than having to write it by hand :slight_smile: (particularly useful if you have so many properties you want to include).

And agreed, we do need to make it easier to work with relevance in general…we’ve a number of ideas there that we’re actively exploring. If you’ve ideas that you want to share on that front, or regarding useful tools in general, please do so!