The Zurich release has arrived! Interested in new features and functionalities? Click here for more

BIGFIX custom API issue

MahmoodU
Tera Contributor

Hi everyone, I’m working on integrating BigFix with ServiceNow using a custom REST call. I’m facing an issue where the API only returns the "name" field in the response, even though I’m requesting multiple columns.

 

Here’s the endpoint I’m calling 

 

https://<ip address>/api/sam/v2/computers?columns[]=id&columns[]=bigfix_id&columns[]=name&columns[]=dns_name&columns[]=ip_address&columns[]=os&columns[]=os_type&columns[]=first_seen&columns[]=last_seen&columns[]=is_deleted&columns[]=deletion_date&columns[]=is_managed_by_vm_manager&token=<token>

 

Here’s the ServiceNow Scripted rest API I’m using to execute the call:

 

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

    try {

        var r = new sn_ws.RESTMessageV2();

        r.setMIDServer('Mid server');

        r.setEndpoint('https://<masked-ip>/api/sam/v2/computers');

        r.setHttpMethod('get');

 

        var columns = [

            'id', 'bigfix_id', 'dns_name', 'ip_address', 'os',

            'os_type', 'first_seen', 'last_seen', 'name'

        ];

 

        columns.forEach(function(col) {

            r.setQueryParameter('columns[]', col);

        });

 

        r.setQueryParameter('token', '<masked-token>');

        r.setRequestHeader("Accept", "application/json");

 

        var response = r.execute();

        var responseBody = response.getBody();

        var httpStatus = response.getStatusCode();

 

        gs.info("Status: " + httpStatus);

        gs.info("Response Body: " + responseBody);

 

        var jsonResponse = JSON.parse(responseBody);

 

        if (!jsonResponse.rows || !Array.isArray(jsonResponse.rows)) {

            gs.error("[BigFix API] No 'rows' array found in response.");

            response.setStatus(500);

            response.setBody({ error: "Invalid response structure from BigFix." });

            return;

        }

 

        jsonResponse.rows.forEach(function(device) {

            var gr = new GlideRecord('u_big_fix_staging');

            gr.initialize();    

 

            gr.setValue('u_id', device.id || "Unknown");

            gr.setValue('u_computer_id', device.bigfix_id);

            gr.setValue('u_name', device.name || "Unknown");

            gr.setValue('u_os', device.os);

            gr.setValue('u_last_report_time', device.last_seen);

 

            gs.info("[BigFix API] Attempting to insert: " + device.name);

            gr.insert();

        });

 

        response.setStatus(200);

        response.setBody({ message: "Data inserted into staging table." });

 

    } catch (error) {

        response.setStatus(500);

        response.setBody({ error: error.message });

    }

})(request, response);

 

 Issue: Even though I’m passing all the required columns[] in the query params, the response only includes the "name" field. Other fields like id, ip_address, etc., are not coming through at all.

 

I’ve confirmed this endpoint works when called directly from webpage, but the full list of fields doesn’t come through in ServiceNow.

 

Has anyone faced a similar issue with BigFix?

0 REPLIES 0