JAMF Rest API: GET

jafuller
Contributor

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?

1 ACCEPTED SOLUTION

cvgs
Contributor II

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"

View solution in original post

1 REPLY 1

cvgs
Contributor II

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"