Using Rest API to find site name for an issued action

Hello

Need some assistance figuring out API string.

When I look in the Bigfix console and looking at all the actions, there is a column named “Site” which I believe indicates where the fixlet was used for that particular action as it shows different site names (some are custom sites and some are external sites)

How do I find this same information using the API. When I run following API using browser, it lists all actions and some other details about the actions but I am not able to find the “Site” information in the results.

https://:52311/api/actions

Or even if I try reading details on just one action, it does not have site information

https://:52311/api/action/<action_id>

Any help is appreciated.

Thanks.

You have to use session relevance in your API query to fetch the desired action details, with default API/Actions or API/Action/XXXX its not feasible.

1 Like

Here’s a sample session relevance query that returns the action ID, name, and site of source fixlets that could be used with /api/query:

(id of it, name of it, display name of site of source fixlet of it | "n/a") of bes actions

Hi Aram, when I try your relevance as below, I get output “Requested resource does not exist.”

https://servername:52311/api/query?relevance=(id of it, name of it, display name of site of source fixlet of it | “n/a”) of bes actions

But if I remove string “, display name of site of source fixlet of it | “n/a”” from the API query, then I get the list of all actions (missing the site name I need)

https://servername:52311/api/query?relevance=(id of it, name of it) of bes actions

IF I only try following query, then I get error “Singular expression refers to nonexistent object.”

https://servername:52311/api/query?relevance=(display name of site of source fixlet of it) of bes actions

and lastly, if I try adding “n/a” in the query like below, I again get “Requested resource does not exist.”

https://servername:52311/api/query?relevance=(display name of site of source fixlet of it | “n/a”) of bes actions

Not sure where the issue is!!

How are you sending the query? The query needs to be URL-encoded (replacing double quotes with %22 and, usually, spaces with %20, for instance). Depending on your scripting language or CURL usage that might be done for you automatically or you may need to do it yourself before sending the query.

Url-encoding.

There’s an action that doesn’t have a source fixlet, so that throws the error message. Custom Actions, Settings actions, etc. don’t have a source fixlet so that is expected.

Jason, I am using Chrome browser and do see that browser is adding %20 for spaces. Here is what it shows up in chrome url bar after execution

https://servername:52311/api/query?relevance=(id%20of%20it,%20name%20of%20it,%20display%20name%20of%20site%20of%20source%20fixlet%20of%20it%20|%20"n/a")%20of%20bes%20actions

Ok so Chrome is handling the spaces for you but is still sending literal double quotes where it should be sending %22 instead.

I have a post at Bes Properties that are not set or unkown causing relevance query issue on using Curl more easily by keeping the query in a text file and having Curl do the url-encoding automatically for you.

To use the query in a browser URL directly, try using an online utility like https://www.urlencoder.org/ to generate the URL-encoded version of your query.

If you feed it

(display name of site of source fixlet of it | "n/a") of bes actions

It returns

%28display%20name%20of%20site%20of%20source%20fixlet%20of%20it%20%7C%20%22n%2Fa%22%29%20of%20bes%20actions

So you could give that a try for the ‘relevance=’ value

Jason, that worked and so does the following queries working as well in the chrome browser.

https://servername:52311/api/query?relevance=(id of it, name of it, display name of site of source fixlet of it%20%7C%20%22n%2Fa%22) of bes actions

https://server:52311/api/query?relevance=(id of it, name of it, display name of site of source fixlet of it | %22n%2Fa%22) of bes actions

https://servername:52311/api/query?relevance=(id of it, name of it, display name of site of source fixlet of it | “n%2fa”) of bes actions

So its the “/” which was causing the issue

Thanks for posting back and clarifying. I think the safest route is to explicitly URL-encode the entire query, either using a URL-encoder site/utility or the curl --data-urlencode option. It seems Chrome is transparently encoding some portions of the query for you, but perhaps isn’t doing it all or doing it all correctly.

I agree and thanks all for your help in this. Much appreciated.