Issue with Zoho Analytics API when adding rows using Postman

Issue with Zoho Analytics API when adding rows using Postman

Dear Zoho Support,

 

I have been encountering an issue while attempting to add rows to a table using the Zoho Analytics API through Postman.

 

My goal is to iterate over all Postman global variables that end with '_Managed_Devices' or '_Managed_Computers', and add a row for each distinct customer to a Zoho Analytics table. The customer name is derived from the prefix of the variable name before '_Managed'. For each customer, I need to add the values of the variables ending with '_Managed_Devices' and '_Managed_Computers' to the 'Managed Devices' and 'Managed Computers' columns, respectively.

 

However, when I attempt to send a POST request to the API endpoint (https://analyticsapi.zoho.com/restapi/v2/workspaces/<workspace-id>/views/<view-id>/rows), I receive a 400 status code with the following error message:

{

  1.     "status":"failure",

        "summary":"LESS_THAN_MIN_OCCURANCE",

        "data":{

            "errorCode":8504,

            "errorMessage":"The parameter CONFIG is not proper(Has not been sent or is less than required count)"

        }

    }

Here's the JavaScript code I have been using in Postman:

  1. let variables = Object.entries(pm.globals.toObject());

     

    let customerData = {};

     

    variables.forEach(([key, value]) => {

        if (key.endsWith('_Managed_Devices') || key.endsWith('_Managed_Computers')) {

            let customerName = key.split('_Managed')[0];

            let column = key.endsWith('_Managed_Devices') ? 'Managed Devices' : 'Managed Computers';

            if (!customerData[customerName]) {

                customerData[customerName] = {};

            }

            customerData[customerName][column] = value;

        }

    });

     

    let index = 0;

    let customers = Object.keys(customerData);

     

    function sendRequest() {

        if (index >= customers.length) {

            return;

        }

     

        let customerName = customers[index];

        let data = customerData[customerName];

        let row = {

            "columns": {

                "CustomerName": customerName,

                ...data

            }

        };

     

        let url = `https://analyticsapi.zoho.com/restapi/v2/workspaces/1932361000000233498/views/1932361000003095084/rows`;

        let headers = {

            'Content-Type': 'application/json',

            'ZANALYTICS-ORGID': '686374358',

            'Authorization': 'Bearer 1000.7bff9da5ed925ea251a9484825181773.af524e4bc307b17446b6a9f4f88e29c2'

        };

        let requestBody = {

            data: [row]

        };

     

        pm.sendRequest({ url: url, method: 'POST', headers: headers, body: JSON.stringify(requestBody) }, function (err, res) {

            if (err) {

                console.log(err);

            } else {

                console.log(res.json());

            }

            index++;

            sendRequest();

        });

    }

     

    sendRequest();

Could you please help me understand what is causing this error and how I can resolve it? I want to ensure that the CONFIG parameter is being used correctly.

 

Thank you for your assistance.

 

Best Regards,