Home > Jamf Pro, Jamf Pro API, Jamf Pro Classic API, Scripting > Jamf Pro Classic API computer inventory endpoint deprecated as of Jamf Pro 11.15.0
As part of the release of Jamf Pro 11.15.0, the computers Classic API endpoint is being deprecated. This endpoint has been used to gather and update information on managed macOS computers for more than 10 years, but it is being replaced over time by the Jamf Pro API’s computers-inventory API endpoint. For more information, please see the link below:
https://developer.jamf.com/jamf-pro/docs/deprecation-of-classic-api-computer-inventory-endpoints
To minimize the disruption caused by this change, there will be a one year period of continued support for the computers Classic API endpoint in order to give folks time to switch to using the computers-inventory Jamf Pro API endpoint.
Probably the biggest adjustment for most folks will be that while the Classic API supports providing output in both XML and JSON, the Jamf Pro API only provides output in JSON. Another change is that the computers-inventory API endpoint supports lookup by Jamf Pro ID number and does not currently offer the ability to directly lookup devices by providing the serial number, MAC address or the other criteria offered by the computers Classic API endpoint. That said, the computers-inventory API endpoint does offer a number of filtering options, including the ability to filter by serial number to get the Jamf Pro ID of a device. For more information, please see below the jump.
As an example of how you can switch from using the computers Classic API endpoint to using the computers-inventory Jamf Pro API endpoint, I have an existing script which had been using the computers endpoint which I’ve now transitioned to using the computers-inventory endpoint:
Using the computers endpoint:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ComputerRecord=$(/usr/bin/curl -sf –header "Authorization: Bearer ${api_token}" "${jamfpro_url}/JSSResource/computers/serialnumber/$SerialNumber" -H "Accept: application/xml" 2>/dev/null) |
Using the computers-inventory endpoint:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jamfproSerialURL="${jamfpro_url}/api/v1/computers-inventory?filter=hardware.serialNumber==" | |
ID=$(/usr/bin/curl -sf –header "Authorization: Bearer ${api_token}" "${jamfproSerialURL}${SerialNumber}" -H "Accept: application/json" | /usr/bin/plutil -extract results.0.id raw – 2>/dev/null) | |
jamfproIDURL="${jamfpro_url}/api/v1/computers-inventory-detail" | |
ComputerRecord=$(/usr/bin/curl -sf –header "Authorization: Bearer ${api_token}" "${jamfproIDURL}/$ID" -H "Accept: application/json" 2>/dev/null) |
In this case, the previous workflow with the computers Classic API endpoint worked like this:
The new workflow with the computers-inventory Jamf Pro API endpoint works like this:
The result was that I had one extra step in my workflow with the computers-inventory API endpoint, but overall updating my script to work with the computers-inventory API endpoint was fairly straightforward.
Another change I needed to make was switching from parsing XML to now parsing JSON, but I was able to handle that by switching from using the xmllint command line tool to using the plutil command line tool, as plutil on macOS Monterey and later has the ability to parse and extract values from JSON. On macOS Sequoia, the jq command line tool is included with macOS and is another option for parsing JSON. The reason I’m choosing to use plutil in my case is to make sure that folks running macOS Monterey and later don’t need to install anything extra for the script to work on their system.