Hi,
I am currently trying to use the Jamf Pro API to run software updates on our Mac environment. I did some testing a few weeks earlier and was able to successfully update a single mac using the API command. Recently I have tried to update a whole room full of macs but receive a http 401 error when running the script. The only change I made to the script was to add the device IDs of the relevant devices.
In order to try and troubleshoot this I removed all the device IDs except for the one I used in my initial test but still receive the 401 error.I have also confirmed that my credentials to Jamf Pro were correct, this is proven by the fact I do receive a valid bearer token when requested. I have also checked all of my Jamf Pro account permissions and I have every available permission assigned. Also the same bearer token is able to run this command.
curl --request GET --url "$url"/api/v1/macos-managed-software-updates/available-updates --header 'accept: application/json' --header "Authorization: Bearer $bearerToken"
I get a valid response with the list of available updates. If I remove the "--header 'Authorization...'" switch I get the 401 error so i believe the bearer token to be valid and not expired as it is necessary to receive a response.
Please see full script below.
user="username"
pass="password"
url="https://JamfProFQDN:8443"
bearerToken=""
tokenExpirationEpoch="0"
response=$(curl -s -u "$user:$pass" "$url"/api/v1/auth/token -X POST)
bearerToken=$(echo "$response" | plutil -extract token raw -)
curl --request GET --url "$url"/api/v1/macos-managed-software-updates/available-updates --header 'accept: application/json' --header "Authorization: Bearer $bearerToken"
curl --request POST --url "$url"/api/v1/macos-managed-software-updates/send-updates --header 'accept: application/json' --header 'content-type: application/json' --header 'Authorization: Bearer $bearerToken' --data '
{
"deviceIds": [
"762",
"763",
"764",
"765",
"766",
"767",
"768",
"769",
"771",
"773",
"774",
"775",
"776",
"777",
"778",
"779",
"780",
"781",
"827",
"837"
],
"skipVersionVerification": false,
"applyMajorUpdate": false,
"forceRestart": true,
"priority": "HIGH"
}
'
Apologies if this has been asked before I had a look and the only post I found about this talks about the Jamf Pro user account permissions which I have already checked.