Skip to main content
Solved

API call on extension attribute name field is not returning results

  • December 1, 2021
  • 1 reply
  • 0 views

Forum|alt.badge.img+8

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

 

 

Best answer by macinblack

This was resolved by adding single quotes around the variable in the xpath command: "//extension_attribute[name='$eaName']".

 

View original
Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img+8
  • Author
  • Contributor
  • 20 replies
  • Answer
  • December 1, 2021

This was resolved by adding single quotes around the variable in the xpath command: "//extension_attribute[name='$eaName']".

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings