API Questions

BND10706
New Contributor

I am trying to build a custom mobile app to add location information for our devices using the asset tags of the mobile device.

Basically enter the asset tag, then select the location and it puts the location information in for that asset tag.

I can seem to be able to put the location information in, but I cannot seem to find anything out for a finding a device with a certain asset tag.

It seems I will have to search every device...

Has anyone attempted this before?

1 REPLY 1

shaquir
Contributor III

Hi @BND10706 I've done something somewhat similar.
I think the /JSSResource/mobiledevices/match/ is what you are looking for.

935c39244c0c43e9b1a0a7fa1949130f

#!/bin/bash

#Applescript prompt to request asset tag
assetTag=$( osascript<<APPLESCRIPT
tell application "System Events" to text returned of (display dialog "Please enter asset tag below:" default answer "" buttons {"OK"} default button 1)
APPLESCRIPT)

#Searches based on what was inputed into the AppleScript prompt
data=$(curl website.com/JSSResource/mobiledevices/match/$assetTag* 
-H "Accept: text/xml" 
-X GET 
-u username:Saltedpassword 
-s )

#Filter the $data result to the the id and perform the rest of your script...