Posted on 10-19-2018 01:49 AM
Anyone seeing any glitchy behaviour from the Classic API today? I've got a dashboard that uses the API to pull data from Smart Groups and only 7-8 of the 15 metrics are updating - the added twist is that each time the script runs to retrieve the data, a different group of metrics update.
The script that pulls the data isn't rocket science, and is scraping the <computer_group><computers><size> value using the following:
total=$(curl -L -skfu user:pass 'https://myjss.jamfcloud.com/JSSResource/computergroups/id/1' | /usr/bin/awk -F '<size>|</size>' '{print $4}')
Having output the values to a text file I can see that the ones that are failing do not contain a number. I can curl the data manually and the <size> looks to be OK however when I pipe the output through xmllint to format for readability, the metrics that I'm seeing fail error with "-:1: parser error : Start tag expected, '<' not found".
I've ruled out local network restrictions as a cause having tried the same script from the office LAN as well as my home VDSL connection and the behaviour is identical.
Any thoughts?
Thanks
John
Solved! Go to Solution.
Posted on 10-19-2018 04:31 AM
Try specifying the format you'd like to receive the data as. Add -H "Accept: application/xml" after the URL. It's likely you're getting JSON back from time to time.
Posted on 10-19-2018 04:31 AM
Try specifying the format you'd like to receive the data as. Add -H "Accept: application/xml" after the URL. It's likely you're getting JSON back from time to time.
Posted on 10-19-2018 04:55 AM
Thanks @leslie - that seems to have done the trick. The dashboard has been working fine for weeks without adding the format, guess I must just have been lucky all that time!