Update mobile device application scope with device exclusion

cw_chris
New Contributor

We have an app installed on devices in our org that needs relatively frequent removal and reinstall. Most frequently, the user provides their serial number, sometimes the asset tag associated with the device (which is in the jamf pro device inventory record). 

jss_url='identifier.jamfcloud.com/'
username=apiuser
password=apipassword
authToken=$(curl -su "$username":"$password" https://"$jss_url"/api/v1/auth/token -X POST)
api_token=$( /usr/bin/plutil -extract token raw - <<< "$authToken" )

#response=$(read -p "enter s/n: ")
response=1070 #this is added for testing adding the device by inventory id 

apidata="<mobile_device_application><scope><exclusions><mobile_devices><mobile_device><id>$response</id></mobile_device></mobile_devices></exclusions></scope></mobile_device_application>"

curl -ks https://"$jss_url"JSSResource/mobiledeviceapplications/id/77 -d "$apidata" -x PUT -H "Authorization: Bearer $api_token"

 Running this in CodeRunner gives an errorScreenshot 2023-01-11 at 11.54.12 AM.png

Running the lines in terminal gives no error but the scope does not update.

I cannot figure out why

1 REPLY 1

gda
Contributor

Update the "x" in your last curl-command to a uppercase "X".

Lower "x" is for proxy configuration.

Uppercase "X" is for request method.