I am somewhat new to making API calls. I am trying understand why the following API call won't return the value held by the "name" field of an extension attribute. However, running the same call, but targeting the "id" field does return the expected value.
Things to note:
- Permissions are correct on the API user account.
- I am able to return the raw XML via curl using the API user account.
- Running on Big Sur & Monterey, and the xpath command is adjusted to reflect syntax changes beginning with Big Sur.
- I am able to retrieve all nodes on the name field using "//extension_attribute[name()]".
Can someone more experienced with API calls throw me a bone?
apiUser="username"
apiPass="password"
apiURL=$(/usr/bin/defaults read /Library/Preferences/com.jamfsoftware.jamf.plist jss_url | sed 's|/$||')
udid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID:/ { print $3 }')
eaName=""insert EA name string value""
eaID=""insert EA ID numeric value""
fromName=$(curl -s -f -u $apiUser:$apiPass -H "Accept: application/xml" $apiURL/JSSResource/computers/udid/$udid/subset/extension_attributes | xpath -e "//extension_attribute[name=$eaName]" 2>&1 | awk -F'<value>|</value>' '{print $2}' | tail -n +1)
fromID=$(curl -s -f -u $apiUser:$apiPass -H "Accept: application/xml" $apiURL/JSSResource/computers/udid/$udid/subset/extension_attributes | xpath -e "//extension_attribute[id=$eaID]" 2>&1 | awk -F'<value>|</value>' '{print $2}' | tail -n +1)
echo $fromName
echo $fromID