We recently created JSL code to collect data from a REST API call. I'm currently on version 18.01 of JMP.
Essentially our application developer has created a scenario where for a specific manufacturing dept. we call in the data in "monthly" blocks, to reduce too much "heavy lifting". We cover 24 months of data backwards from today. We then combine each month's data into a data table then perform our analysis on the fully populated data table.
Ultimately, we intend to publish this report to JMP-Live and there-in lies our issue. I did a quick publish to JMP-Live where the REST API call is utilized, however it failed to run, I suspect its due to the JSON Parser Add-In we loaded into JMP.
Per the code below you can see 2 critical lines where the JSON Parser Add-In comes into play...
// Parse JSON and build table
json = JSON:Parse(result);
tempDT = JSON:Make Table(json);
Perhaps there is a better way of accomplishing our end results, or do we need to make the JSON Parser Add-In available in the JMP-Live environment?
Best regards,
John
Names Default To Here(1);
// Create empty Combined Results table
finalTable = New Table("Combined Results");
// Loop through month offsets
For(month = 1, month <= 24, month++,
Try(
// Build and send request
request_url = "https://XXXX-XXX.XXXXXXX.net/XXXX/api/xX.X.X./XXX/dept/dt/month_offset/" || Char(month) || "/met_test_results" ;
result = New HTTP Request(URL(request_url), Method("GET")) << Send;
// Parse JSON and build table
json = JSON:Parse(result);
tempDT = JSON:Make Table(json);
// Append only if rows exist
If(NRow(tempDT) > 0,
// Add MonthOffset column
tempDT << New Column("MonthOffset", Numeric, Set Each Value(month));
// Append to final table
finalTable << Concatenate(tempDT, Append to First Table);
Write("Month " || Char(month) || ": Data added to Combined Results.\n");
,
Write("Month " || Char(month) || ": No data returned — skipping.\n");
);
// Always close the temp table
Close(tempDT, NoSave);
,
Write("Skipping month offset " || Char(month) || " due to error or bad response.\n");
);
Wait (0.25) ;
);
// Show final table if it has any rows
If(NRow(finalTable) > 0,
finalTable << Set Name("Combined Results");
finalTable << Show Window,
New Window("No Data", Text Box("No valid data returned from selected months."))
);
// Assuming finalTable is already your active data table
dt = finalTable;