Skip to main content
Answer

JAMF Rest API: GET

  • March 20, 2012
  • 1 reply
  • 3 views

Forum|alt.badge.img+9

I'm using the following to try to extract computer information out to an XML file.

Via Terminal (command wraps in this box): curl –u username:password https://jss.domain.com:8443/JSSResource/computers/name/jafuller674382/subset/General&Location&Extention%20Attributes –o "/Users/jafuller/Desktop/jafuller674382.xml"

I need to get the data from the General tab (works), Location tab (doesn't work) and Extension Attributes (doesn't work).

Can you clarify what syntax would be needed here?

Best answer by cvgs

You have to enclose the curl URL in quotes, otherwise the shell will capture the ampersand.

Below is a snippet from a working script, adapt freely to your environment:

#!/bin/bash

MY_JSS_BASEURL=$( /usr/bin/defaults read /Library/Preferences/com.jamfsoftware.jamf jss_url )
MY_JSS_APIURL="${MY_JSS_BASEURL}JSSResource/"
CURL_OPTIONS="--silent --show-error --connect-timeout 30"

/usr/bin/curl ${CURL_OPTIONS} --output "${MY_TMPFILE}" --request GET --user "${MY_API_USER}":"${MY_API_PASS}" 
  "${MY_JSS_APIURL}computers/macaddress/${MY_MAC_ADDRESS}/subset/general&location&extension_attributes"

1 reply

Forum|alt.badge.img+9
  • Contributor
  • Answer
  • March 20, 2012

You have to enclose the curl URL in quotes, otherwise the shell will capture the ampersand.

Below is a snippet from a working script, adapt freely to your environment:

#!/bin/bash

MY_JSS_BASEURL=$( /usr/bin/defaults read /Library/Preferences/com.jamfsoftware.jamf jss_url )
MY_JSS_APIURL="${MY_JSS_BASEURL}JSSResource/"
CURL_OPTIONS="--silent --show-error --connect-timeout 30"

/usr/bin/curl ${CURL_OPTIONS} --output "${MY_TMPFILE}" --request GET --user "${MY_API_USER}":"${MY_API_PASS}" 
  "${MY_JSS_APIURL}computers/macaddress/${MY_MAC_ADDRESS}/subset/general&location&extension_attributes"