Jamf Pro Classic API computer inventory endpoint deprecated as of Jamf Pro 11.15.0
Jamf Pro Classic API的computer inventory端点已弃用,建议迁移到computers-inventory API。Classic API支持XML和JSON输出,并可通过序列号、MAC地址等查询设备;而新API仅支持JSON输出,并需通过过滤获取设备ID。Classic API将继续支持一年以减少影响。 2025-3-21 14:10:3 Author: derflounder.wordpress.com(查看原文) 阅读量:16 收藏

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

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:

https://github.com/rtrouton/rtrouton_scripts/blob/77cc8dc12a0e72a42be277163b7551b08c281b07/rtrouton_scripts/Casper_Scripts/Generate_Mac_Report_From_Jamf_Pro_Serial_Numbers/Generate_Mac_Report_From_Jamf_Pro_Serial_Numbers.sh#L229


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:

https://github.com/rtrouton/rtrouton_scripts/blob/main/rtrouton_scripts/Casper_Scripts/Generate_Mac_Report_From_Jamf_Pro_Serial_Numbers/Generate_Mac_Report_From_Jamf_Pro_Serial_Numbers.sh#L204-L211


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:

  1. I provided a device’s serial number.
  2. I did a lookup for the device’s serial number against the computers endpoint using its serialnumber lookup function. (Hopefully this is just one device, since we’re searching by the device’s serial number.)
  3. Using the serial number as the identifier, I downloaded a copy of the matching computer’s computer inventory record and stored it in the script’s ComputerRecord variable.

The new workflow with the computers-inventory Jamf Pro API endpoint works like this:

  1. I provided a serial number.
  2. I did a lookup for the device’s serial number against the computers-inventory API endpoint using its filter for device serial numbers to see which devices matched the filter. (Hopefully this is just one device, since we’re searching by the device’s serial number.)
  3. Script parses the results list provided by the API and gets the Jamf Pro ID from the first device in the list.
  4. Using the Jamf Pro ID as the identifier, I downloaded a copy of the matching computer’s computer inventory record and stored it in the script’s ComputerRecord variable.

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.


文章来源: https://derflounder.wordpress.com/2025/03/21/jamf-pro-classic-api-computer-inventory-endpoint-deprecated-as-of-jamf-pro-11-15-0/
如有侵权请联系:admin#unsafe.sh