Cannot retrieve computers using API

Hi, im having some weird behavior with the API that im unsure how to continue debugging as im not sure if its a bug or not.

What im doing is the following:

  1. Get all computer groups using GET /api/computergroups/<site>
  2. Using the output of 1 get some of the computer group details, GET /api/computergroup/<site>/<id>
  3. Collect the list of computers for each computer group in 1 using GET /api/computergroup/<site>/<id>/computers
  4. Get some of the computer details for each computer in 3 using GET /api/computer/<id> (This does not work for some of the computers returned in the list for 3 and Im not sure where to start looking as to why)

When getting some of the computers in step 4, I get 404 Resource Not Found, even though its clearly listed in the computer groups computer output.

Any ideas what can cause this?

I do not have any real answers, but I will say that we have experienced many buggy behaviors using the REST API.

What is the version of your root server / web reports server? 9.???

What are you trying to accomplish? Might it be more easily done through session relevance, using either the SOAP API or the REST API /api/query/ ?

Yea, this isnt the first buggy behavior ive hit either, I had a similar problem with getting fixlet listings for external sites.

We are using 9.1.1117.0 .

I started down the path to writing a relevance query and failed miserably. Im trying to retrieve the computer name, dns name, id, and os for the short term for a computer of a specific id (I was just caching the whole computer XML and extracting from there or at least trying to if it had worked).

Session relevance:

(name of it, hostname of it, id of it, operating system of it) of bes computers whose(id of it = 12345)

Have you tried writing your session relevance in this? : http://support.bigfix.com/labs/relevanceeditor.html

1 Like

Thanks,

I havent used the console for much of anything, ive been mainly work through the API, ill give it a look though since it seems easier than trolling through the doc.

Session relevance is different than the API, but the api/query uses session relevance. The thing I linked above is to help write session relevance against your web reports server using the SOAP api.

Session relevance can be used in many places, including the console, dashboards, wizards, SOAP API, REST API, etc…

So actually, you can use the REST API to actually make relevance queries:

https://YOUR_TEM_SERVER.com:52311/api/query?relevance=names%20of%20bes%20computer%20groups

Will return stuff like:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
	<Query Resource="names of bes computer groups">
		<Result>
			<Answer type="string">Alpha Machines</Answer>
			<Answer type="string">Beta Machines</Answer>
		</Result>
		<Evaluation>
			<Time>0.192ms</Time>
			<Plurality>Plural</Plurality>
		</Evaluation>
	</Query>
</BESAPI>

So if you can write it through session relevance, you can get it back through REST API.

1 Like

I get the same results even with the query (at least for the computer id im having issues with). The query doesnt throw an 404 Not Found like the GET /api/computer/<id> did but instead just returns no result…

I think this may be a bug after all unless it has something to do with the state of the computer/client?

Does the REST API work at all or are you just having problems evaluating for a specific computer ID?

If you hit:

https://YOUR_TEM_SERVER.com:52311/api/operators

for example, do you get a list of all of your operators?

Yes it does work for me, its just not working for specific computer id’s listed in whats returned by /api/computergroup/<site>/<id>/computers. If I ignore the exception im able to process the rest (didnt check how many didnt process though). However on a different lab server (not the production one ive been using for the above), I have a site without about 10 computers listed and its not able to retrieve computer data for any of the listed computer id’s.

[Edit] I figured out the problem, it is definitely a bug in the API most likely. What I am finding is that /api/computergroup/<site>/<id>/computers for a particular computer group G is returning a list of about 73 computer ids. However, when I check that same computer group G in the console, it actually only has 32 servers in it. When I ignore the exceptions for retrieving details for those 73, I actually get back the 32 that are really there.

Using relevance is a great way to get this info;
Just thought I’d ask if you’ve seen my post on powershell api queries, right?
see my post in response to What permissions are needed for REST API GETs?

You can also use try/catch in p/s scripts, of course.

All best,
celty

I got it working eventually with some direction from support, it turns out it was a known bug described here:

I ended up just running a query to get exactly what I wanted instead:

ids of members of bes computer groups whose(id of it = COMPUTER_GROUP_ID)
1 Like