cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

ThingWorx Navigate is now Windchill Navigate Learn More

Translate the entire conversation x

Message ::TypeError: Cannot call method "GetJSON" of null

IA_10816220
12-Amethyst

Message ::TypeError: Cannot call method "GetJSON" of null

Hi, 


I have a Scheduler that execute this code :

// Define the Thing that contains the service
me.flag1 = 1;
// Call the service (e.g., GetAPIData) of the API Thing
Things["Eastern.SecurityVehiclesAPI.parser"].GetAPIData();
logger.warn("Tracking.API.Scheduler_3 subscriptionToCallTheService executed");
me.flag1 = 2;

 
and here is the service code itself 

//code
// API endpoint and headers

var apiUrl = "http://212.70.49.13/ewe.agent/api/v1/online-history/fleet/2100/all-vehicles";
var headers = {
    "Accept": "*/*",
    "Accept-Encoding": "gzip, deflate, br",
    "ApiKey": "xxxxx" // Replace with your actual API key
};
logger.warn("getapidata 2");

//var result = contentLoader.GetJSON(params);

// Make the HTTP GET request
    var result = Resources["ContentLoaderFunctions"].GetJSON({
        url: apiUrl,
        headers: headers,
        timeout: 10000 // Timeout in milliseconds
    });
logger.warn("getapidata 3");
    // Store the response in a property or return it
	me.APIResult = result;
	//logger.warn("API Response: " + JSON.stringify(result));


the service itself when i run it it works fine without any errors , but when the Scheduler runs it i get this error: 
Error in: Eastern.SecurityVehiclesAPI.parser.GetAPIData javascript service. Message ::TypeError: Cannot call method "GetJSON" of null (GetAPIData#15)

please note that this service and scheduler used to work on another platform and was fine so i am sure that the codes are correct, also both platforms run the same thingworx version 

so what might be wrong or even how to debug more for this one ?

thanks 

ACCEPTED SOLUTION

Accepted Solutions

The user executing the subscription may not have the necessary privileges (Visibility) on the Resources entity so it can't access the ContentLoaderFunctions. So check the user you entered in the scheduler.

View solution in original post

1 REPLY 1

The user executing the subscription may not have the necessary privileges (Visibility) on the Resources entity so it can't access the ContentLoaderFunctions. So check the user you entered in the scheduler.

Announcements


Top Tags