Using API for software updates.......

fedagain
Contributor

How is the below code / script to be used in conjunction with the Jamf API?

Also, the url "yourserver".jamfcloud.com - I've tried our server name but no go. We used to be on-prem and now we're jamfcloud, anyone know of to get the name it's looking for?

Thank you!

 

curl --request POST \
--url https://yourserver.jamfcloud.com/api/v1/macos-managed-software-updates/send-updates \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--data '
{
"skipVersionVerification": false,
"applyMajorUpdate": false,
"forceRestart": false
}
'

2 REPLIES 2

AJPinto
Honored Contributor II

It should be "yourserver".jamfcloud.com, though I would expect this to need credentials to use JAMF API.

mdp
Contributor

Here's a sample full, working MacOS update call that worked with my Jamfcloud instance:

#!/bin/bash
#Matthew Prins 2022
#https://github.com/MatthewPrins/Jamf/

#Sample of using API with software updates

###########################
#Editable variables

#Jamf credentials
username="xxxxxx"
password="xxxxxx"
url="https://xxxxxx.jamfcloud.com"
	
#############################

#Token function -- from https://developer.jamf.com/jamf-pro/docs/jamf-pro-api-overview
getBearerToken() {
	response=$(curl -s -u "$username":"$password" "$url"/api/v1/auth/token -X POST)
	bearerToken=$(echo "$response" | plutil -extract token raw -)
	tokenExpiration=$(echo "$response" | plutil -extract expires raw - | awk -F . '{print $1}')
	tokenExpirationEpoch=$(date -j -f "%Y-%m-%dT%T" "$tokenExpiration" +"%s")
}

#get token
getBearerToken 

curl --request POST \
--silent \
--url $url/api/v1/macos-managed-software-updates/send-updates \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header "Authorization: Bearer ${bearerToken}" \
--data '{"skipVersionVerification": false, "forceRestart": false, "groupId": "33"}'
---
Matthew Prins -- Jamf Scripts @ Github