Getting Saved Reports from REST API

I am trying out the REST API for the first time, just trying to access some saved report views. I’m following the API documentation, doing: https://server_host_name:port_number/api/reports/report_ID?token=mytoken

However, when I do this, it just gives me back the column headers without any actual data. How can I make it actually give me the data from the saved report?

We are on v9.2.14.0

are you talking about the saved reports in ILMT?

if it is ILMT/BFI, the reports ID API will most likely just give the metadata extract of the specific report, and you will have to build a separate query to fetch the required columns to get the report data

1 Like

Aha, thank you! That was not obvious at all from the documentation!

Hello, were you ever able to figure out how to get saved reports from rest api?

@cm_developer Yes, I had to do two queries, one to get metadata, and then another to actually get the data

I’m new to this. Can you share how you went about it? Also, where did you get the documentation on how to https://server_host_name:port_number/api/reports/report_ID?token=mytoken? Did you used a web application to connect to the REST API? I’m using PHP but not sure how to connect to the web reports to pull the reports. My analysts create the reports in web report and I just know how to download it once logged into web report. I would like the php web application to connect to web report using credential, of course, and download the report. Can you help?

Actually, I take that back - I didn’t end up using a saved report. I don’t remember why, exactly, but maybe I needed some additional data that wasn’t in that report. Instead, I just ran my own custom query. Here’s my basic code for that (in Python):

def get_token():
    """Get token to work with BFI REST API"""
    r ="https://mybfiserver:9081/api/get_token",
                  data={"user": BFI_USER, "password": BFI_PASS},
                  headers={"Content-Type": "application/json"},
    return r.text

def get_metadata(url, params):
    """Get row total and column headers"""
    req = requests.get(url, params=params, verify=False).json()
    # Get column names
    keys = flatten(req['rows'][0]).keys()
    return req['total'], keys

token = get_token()
params = {
    "token": token,
    "criteria": # Query params here
    "limit": 1
url = "https://mybfiserver:9081/api/sam/v2/software_instances"
total, keys = get_metadata(url, params)

# Set limit/offset if needed
params["limit"] = 100000
params["offset"] = 0
req = requests.get(url, params=params, verify=False).json()

This is just for a single large request, but you can break it up and page through the results if needed as well.

1 Like

Thanks anyway. I don’t know enough of BigFix to perform my own customize queries and analysts only know how to use web report web interface, not how data are stored in database.

Neither did I when I started this. I used Chrome DevTools to see what queries the web interface was sending to the API and then modeled my code after that.