Skip to main content
Question

Getting data out of a json file from an API call

  • May 14, 2026
  • 3 replies
  • 28 views

Hello there, Im a bit rusty so any help would be appreciated.

Im writing a script in jamf pro which uses the computers-inventory API to grab info on a specific computer. So far I have this

computerID=$(sudo jamf recon | grep computer_id | cut -f2 -d '>' | cut -f1 -d'<')
computerInventory=$(curl -s "${apiURL}/api/v3/computers-inventory/${computerID}" -H "Accept: application/json" -H "Authorization: Bearer ${apiBearerToken}" -X GET)
#EXTRACT managementID out of computerInventory

I have no idea how to extract the managementID field out of computerInventory. Im trying to avoid jq cause I dont want to deploy that to all the macs in the fleet.

Any help would be amazing.

3 replies

Shane Bucher
Forum|alt.badge.img
  • New Contributor
  • May 14, 2026

Hello there, Im a bit rusty so any help would be appreciated.

Im writing a script in jamf pro which uses the computers-inventory API to grab info on a specific computer. So far I have this

computerID=$(sudo jamf recon | grep computer_id | cut -f2 -d '>' | cut -f1 -d'<')
computerInventory=$(curl -s "${apiURL}/api/v3/computers-inventory/${computerID}" -H "Accept: application/json" -H "Authorization: Bearer ${apiBearerToken}" -X GET)
#EXTRACT managementID out of computerInventory

I have no idea how to extract the managementID field out of computerInventory. Im trying to avoid jq cause I dont want to deploy that to all the macs in the fleet.

Any help would be amazing.

Usually I use JQuery so, all you work do would attach a pipe then “jq -r” then based on the fields you would filter out what you want.

 

For this api specifically, to get the management id i used the jquery result ‘.results[].general.managementID’
 

curl -X GET "https://${url}.jamfcloud.com/api/v3/computers-inventory" \
-H 'accept: application/json' \
-H "authorization: Bearer $token" | jq -r '.results[].general.managementId'


 


Chubs
Forum|alt.badge.img+26
  • Jamf Heroes
  • May 14, 2026

jQuery is your friend to extract/parse the data.  Everything usable is in json now...xml went out long ago.

What’s your overall goal and I can craft a script and post it.


talkingmoose
Forum|alt.badge.img+36
  • Community Manager
  • May 14, 2026

Adding that Apple started shipping jq beginning with macOS Sequoia 15. You’ll find it at /usr/bin/jq.