REST API for gathering asset data

I am trying to create some integrations with a local system and seem to be having issues with a REST API call using the Query options. I am trying to get the most basic information that is found for all assets: Computer ID, Computer Name, Last Report Time, IP Address, and OS

Here the call that I am using:

https://SERVER:52311/api/query?output=json&relevance=(ids of it, names of it, last report time of it, concatenation " " of values of result (it, bes properties “IP Address”), operating system of it) of bes computers

It returns about 10% of the total assets and then I get
Singular expression refers to nonexistent object.

I went through process of elimination and when I remove “operating system of it” I get the data for all the data for all the assets.

I looked at the machines in the console and expanded by OS, I removed the one machine with and it did not change. I removed the 13 machines with and it seemed to pull more assets but still ended up with the same error message at the end. I noticed a couple assets have for computer ID too so not sure if its related to that.

Is there any way to do the calls if there are assets in this state, shouldnt it just skip over them if the value does not exist?

Yes, you can tune your query in a couple of ways.

If you switch all of the values to plurals, it will discard the entire record for any properties that are not reported.
A better option is to use the pipe operator (" | ") for error handling. If the left side of the pipe generates an error, the right side is substituted. So try

(id of it, name of it | "[name not reported]", last report time of it, (concatenation " " of values of result (it, bes properties “IP Address”) | "[ip address not reported]"), (operating system of it | "[operating system not reported]")) of bes computers

Once you get that working though, check out @brolly33’s excellent blog entry on how to pull the results more efficiently. Direct link is at Legacy Communities - IBM TechXchange Community

The way you’re looking it up should work okay at a small scale - but realize that for each bes computer, you are performing a new lookup to find the IP Address property (iterating through every existing property, and then repeating that process again for each additional computer). @brolly33’s form is a little more complex to read, but gives huge performance benefits at scale.

3 Likes

This resolved an issue we were having with an incomplete computer object. Either the BigFix agent was not functioning or the computer was not connected long enough to provide basic inventory which caused the query we were using to get stuck on the offending computer and not return any more objects. Once we provided error checking the issue went away.

1 Like