Hey - so I've learned how to use what I think we are now supposed to call the legacy Rest API in various useful ways. One I have been working on is a powershell (I have my reasons) which emails the total results from various existing "reports" aka inventory searches or advanced computer searches in JAMF to specific recipients. For example, say I have two reports on "Disk Encryption Compliance" and "Security Agent Compliance" - I use the API to search out those two reports by name like so:
[xml]$JAPInfo = Invoke-WebRequest -Uri https://jss:8443/computerreports/name/$reportname -Credential $secureCreds #-Verbose
I then have some logic to loop through my list of desired report names and get counts of members in each report and relate that as percentages of the number of Macs in my fleet or other criterion, then email that as a simple table:
![sample outlook report view]
But what I would really put the icing on the cake for this report would be to pull down another report, "All non-compliant devices" as a csv file, very much like I do manually now by clicking on that saved computer search, clicking view, clicking report, then clicking download report and getting a nice CSV. Alternately, I could construct this as a Smart Computer Group, then view it, then click export, select the csv radio button, click next, and computers then next again to download the csv of that report.
Is there a way to get the actual report csv via the API? I know I can compile it somewhat from the requests I'm invoking above, but that XML doesn't seem to contain everything that I've set to display in the report (for example, my compliance criteria usually determined through extension attributes, and in my "all non-compliant devices" report I'd want to show all the different extension attributes I look at. The canned report does this nicely to a csv, whereas I'd be stuck converting the json or xml output from the API to csv to then dump to a file that I then attach back into the email report. I'd much prefer if there were something like:
$ReportCSV = Invoke-WebRequest -Uri https://jss:8443/computerreports/name/$reportname/export-as-csv -Credential $secureCreds #-Verbose
$ReportCSV | export-csv \\path omy
oncompliant.csv
Send-MailMessage @EmailParameters -Body ($Html1 + $Html2 + $privacydisclaimer) -BodyAsHTML -Attachments \\path omy
oncompliant.csv