Skip to main content
Solved

Classic API

  • October 19, 2018
  • 2 replies
  • 37 views

Forum|alt.badge.img+7

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

Best answer by leslie_h

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.

2 replies

leslie_h
Forum|alt.badge.img+14
  • Employee
  • Answer
  • October 19, 2018

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.


Forum|alt.badge.img+7
  • Author
  • Contributor
  • October 19, 2018

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!