Skip to main content
Question

Bad at API syntax - How to get site name from a computer's UDID?

  • September 25, 2019
  • 5 replies
  • 0 views

Forum|alt.badge.img+6

Hi all.

I am still struggling so hard with API and bash syntax, due to lack of training. :-/

As I have a time-sensitive and crucial task to fulfill that does not leave so much time left for trial and error, could someone hint me how to get a site name (and define it as variable $site) via the Mac's UDID through API?

What would the curl call (and the formatting) need to look like?

Thanks a million! :-)

Chris

5 replies

leslie_h
Forum|alt.badge.img+14
  • Employee
  • 100 replies
  • September 25, 2019

This work for you?

curl -sku "apiUser:password" https://your.jamfcloud.com/JSSResource/computers/udid/<UDID here>/subset/general -X GET -H "Accept: application/xml" | xpath "string(//site/name)"

Forum|alt.badge.img+6
  • Author
  • Contributor
  • 21 replies
  • September 27, 2019

Sorry, with that, I get:
Query didn't return a nodeset .


leslie_h
Forum|alt.badge.img+14
  • Employee
  • 100 replies
  • September 27, 2019

And it didn't return the site? You can silence that message as follows:

curl -sku "apiUser:password" https://your.jamfcloud.com/JSSResource/computers/udid/<UDID here>/subset/general -X GET -H "Accept: application/xml" | xpath "string(//site/name)" 2>/dev/null

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • September 27, 2019

Try it this way. If there is a Site assigned to the Mac or not, it should return something. Even if one is not assigned it returns a string of "None"

curl -sku "apiUser:password" https://your.jamfcloud.com/JSSResource/computers/udid/<UDID here>/subset/general -X GET -H "Accept: application/xml" | xpath '/computer/general/site/name/text()'

Forum|alt.badge.img+1
  • New Contributor
  • 5 replies
  • October 9, 2019

These require that the device is checking in, correct? If a device has not checked in or updated inventory since this is in place, is it pulling from information currently in the DB or only after it has responded regularly?


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