API Get Devices

user-cJuKasFEVF
New Contributor II

Hi!

Started last week with the task to build a script which counts the number of our devices. Starting with a few basics i am now able to connect to the API via Powershell getting some data. Access over: https://oursubdomain.jamfcloud.com/api/apps or /locations or /users works fine.

Now i'm trying to get the list of devices. Unfortunately i always get a timeout after a few minutes of waiting (approx. 24k devices). Moreover i am not able to search a device rather with "/devices/id/1" nor "devices/1". Also tried the serial number /devices/serialnumber (found at the web frontend) as identifier with no results .

I am a bit confused with the different "kind" of API:
For example, https://oursubdomain.jamfcloud.com/JSSRessource/locations and /uapi/docs returns a 404 Page not found

https://oursubdomain.jamfcloud.com/api/JSSRessource/locations
returns "{"error":{"code":404,"message":"Not found"}}"

Am I doing something fundamentally wrong??

Thanks in advance for your help! :-)

5 REPLIES 5

user-cJuKasFEVF
New Contributor II

okay i found new information: https://oursubdomain.jamfcloud.com/api/devices gives no response due to too much responses - return of 504 Gateway time-out..
if i use https://oursubdomain.jamfcloud.com/api/devices/<udid> i get one response but i can not search https://oursubdomain.jamfcloud.com/api/devices/serialnumber/<serialnumber>

SamF
Contributor II
Contributor II

It sounds like you might be conflating the various Jamf APIs and products. Jamf School has an API, with public documentation available here. Jamf Pro has two APIs, the Classic API and Jamf Pro API, both with documentation available here.

If you can clarify what product you're using, that'll help identify what workflow/API would be best to accomplish your goal.

user-cJuKasFEVF
New Contributor II

Thanks for your reply Sam.
I'am using Jamf School and used the public documentation. I was a bit confused due to the given endpoint https://api.zuludesk.com/

So now, i found three possible endpoints (https://api.zuludesk.com/, https://apiv6.zuludesk.com/ and https://oursubdomain.jamfcloud.com/api/) which return the information.
Unfortunately with /devices i still get the 504 Gateway time-out with every of those endpoints.

I am using the Powershell Invoke RestMethod with the http Basic Authorization header:
$credPair = "XXXXXXX:YYYYYYYYY"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($credpair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{"Authorization" = $basicAuthValue; "Content-Type" = "application/json; charset=utf-8"}
$result = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers -Proxy "http://our_web_proxy:8080" -ProxyUseDefaultCredentials

As i mentioned before works great for locations and apps where there are not as much results as with the devices.

for me with a python implementation the get device methode works for the list of endoint urls (https://api.zuludesk.com/, https://apiv6.zuludesk.com/ and https://oursubdomain.jamfcloud.com/api/) Thanks for this list, previously i only used the api.zuludesk.com url, but the jamfcloud looks more future save. But dont know.

 

But i experiencend an different problem, the api for /teacher and /dep returns always a 404. I am only able to perform actions with the /users and /devices

 

in this post i demonstrate a basic restart script via Api and the use of python https://community.jamf.com/t5/jamf-school/help-with-api-restart-script-for-ipads-on-jamf-school/m-p/...

Caspernewbie202
New Contributor II

Hi All

Looking for some help - assistance- moral support :)
Unlike many enterprises - we have had a hard time getting JIM integrated in order to get ldap working for JAMF cloud--- Mostly software allocations
Instead of going yet another manual route due to security restrictions - and lack of ldap in my jamf instance- im looking to injecting this via an API.
Obviously would need to be complex- and doable in python - but not sure where to start with jamf API
To give you a mental picture
An python job running internally to fetch ldap attributes of xx macOS users (easily done)
Feed the info to the API of jamf- not sure which reference to use to populate such in a put command as its pretty customized
This is mostly for "memberof" assertion of logged in user/machine owner to be fed into an extension attribute- and use the extension attributes (complete list of ldap groups associated to user-- parsed) and use that to scope software.

Anyone doing something similar in the community without the availability of ldap but making something or fabricating something in aiding them for software allocation (licensed software, ect)

Please share your feels- thoughts- on how to go about doing this!

Thanks so much!!!!