Bigfix webports json output

It appears that WebReports still doesn’t allow Session Relevance output in JSON format, but when did WebReports support the URL endpoints for returning computer data in JSON format (…/json/computers/…) ???

https://webreportsurl/json/computers?Username=xxxxx&Password=xxxxx&startIndex=0&results=10000&q=&c=Computer%20Name&c=RAM

This post says 9.5.8 but I don’t see anything in the Wiki release notes for it and https://developer.bigfix.com/other/web-reports-api/ also doesn’t mention it. This is so useful and I wish I could have been using it for years!

Actually, REST API does allow for outputting session relevance queries in JSON format…

That’s the BES Root Server Service’s API. I’m specifically talking about WebReports APIs.

What you have is an undocumented API designed to be used only by the Web Reports UI. While there is nothing stopping you from using it, it may change at any time and HCL will not offer any guarantee it won’t disappear in the next release.

With that being said, @Scott did do an awesome job of documenting the API using what he observed via the Web Reports UI XHR calls in his Feb 2018 post and should you wish to leverage this technique (again, with the major cavate that it may change/disappear tomorrow) I would say have fun :wink:

One additional thing to note: when you provide a username/password in the URL, you are causing an authentication lookup on each and every query. While a few here and there won’t cause any trouble, if you are performing hundreds or using an LDAP account things can start to bog down. You might want to use the following flow in any multi-query scripts:

  1. Login to Web Reports (using Username/Password) and obtain a session cookie
  2. Send that session cookie along with your queries (but do not use the username/password arguments in the URL)
  3. If the server responds back to your query with an updated session cookie, throw away the previous one and use the new cookie in the next query.
  4. If after X queries or Y minutes you get an HTTP 401 to your queries, goto #1.

Depending upon your scripting language and/or method of calling the URL, there will be different methods you can use for this. Most tools and functions today allow you to maintain state between calls either in a session variable or cookie file. Look at your documentation for the method/switch.

For example, using PowerShell:

# Initial call to login
Invoke-RestMethod -Uri https://web_reports_login_url -SessionVariable WR_SESSION

# Subsequet calls
Invoke-RestMethod -Uri https://web_reports/json/computers?.. -WebSession $WR_SESSION