API Rules - not listing all my rules

im on 2024 R1 , and following the REST API docs from here:

https://doc.developer.milestonesys.com/mipvmsapi/api/config-rest/v1/#tag/Rule/operation/getAllrules

when i GET the /rules endpoint (“Get array of all enabled Rule”) - only some of my rules show up. For example all of my rules that involve Audio alerts based on camera motion events (from axis cameras, to axis network speakers) do not show up.

1- why do these rules not show up? (they are enabled)

2- how can i get the ID for these rules that are not showing up, so i can use that ID in other API endpoints?

note- even when i hold CTRL then show XML on the rules, im not seeing a valid ID in the .xml text file it shows (ie a valid ID that i can use in the API- even fro the rules that do show up from the GET /rules endpoint)

thanks

There are some rules that isn’t supported by the Rest API (and Configuration API).

The list can be found here, under “rules configuration”.. - https://doc.developer.milestonesys.com/html/index.html?base=gettingstarted/intro_configurationapi.html&tree=tree_4.html

The Configuration API and the Rest API share the same underlying functionality and are missing support for a some objects. This is why you find a list of unsupported rules and you find in “Introduction to Configuration API”

thanks for the reply / answer.

That is a bit frustrating as it goes against the purpose of an API (ie you should be able to do everything via the api , as you can in the gui, within reason - Especially when it comes to something like configuration. I see this was listed as a limitation as of milestone 2021 R3, so that should have been addressed/added by 2024 r1 (in my opinion).

also, ive never seen that doc you linked to stating the limitation (lots of great info in there, thank you for that!) A limitation like this should be stated in the actual rest api docs, or at leaste have a link to this more detailed api doc , somewhere on the rest api docs.

im referring to this as the “actual rest api docs”:

https://doc.developer.milestonesys.com/mipvmsapi/api/config-rest/v1/#section/Introduction/Configuration

In case it helps others: what I was trying to do for the past day or so is a client wanted to be able to mute their audible alarms on motion from their crestron panels → milestone (ie for when having a party or an event with alot of trusted motion). the setup is axis cameras → object analytics (line cross) → milestone XP 2024 (which triggers a XP rule which sends an audio alert sound to several axis network cabinet speakers around the location​).

my plan was to use the XP api to toggle a enable/disable the 3x XP rules, when a button pressed on the Crestron panels. (i obviously ran into this issue as you cant modify XP rules that use audio alerts, via the API).

work-around solution; the axis speakers are in a Speaker group, so pull the IDs of any speakers in XYZ speaker group, and set them to enabled=false. (then when button is toggled again, do the same, but set enabled=true on each speaker). (also had to work around the api not showing the ids of disabled devices, via adding ?disabled :pensive_face: ).

it all worked out, and i also have the script send a alert tone (out of the speakers) via user-events when the script runs (as a confirmation that command was run)

here is script if it helps anyone (this runs on a local server against a local milestone 2024r1, not over internet) (i would like to see more CURL based examples in the API docs, this is a common practice in api documentation) :

#!/bin/bash
#
# set -x 
 
 
USERNAME="SpeakerScript"
PASSWORD="XXX"
BASE_URL="http://XXX9/API/rest/v1"
 
# Check if an argument is passed
if [ -z "$1" ]; then
  echo " ------- "
  echo "Usage: $0 {enable|disable}"
  echo " ------- "
  exit 1
fi
# Set the action based on the argument above
ACTION=$1
 
getAuthToken() {
    # Define headers and body
    headers="Content-Type: application/x-www-form-urlencoded"
    body="grant_type=password&username=SpeakerScript&password=XXXX&client_id=GrantValidatorClient"
 
    # Make the POST request and store the response
    response=$(curl -s -X POST -H "$headers" -d "$body" 'http://x.x.x.x:8081/idp/connect/token')
 
    # Output the response in JSON format
	authTOKEN=$(echo "$response" | jq -r .access_token)
}
 
# Play alert noise when rules are ENABLED or DISABLED via a milestone User-defined Event
play_sound_alert() {
local user_event_ID="2abc090b-87ab-4691-8349-XXXXXX"
  curl -X POST "${BASE_URL}/events" \
    -H "Authorization: Bearer ${authTOKEN}" \
    -H "Content-Type: application/json" \
    -d "{
      \"type\": \"${user_event_ID}\",
      \"datatype\": \"none\"
    }"
}
 
disable_speakerOnly() {
local speaker_id="$1"
  curl -X PATCH "${BASE_URL}/speakers/${speaker_id}" \
    -H "Authorization: Bearer ${authTOKEN}" \
    -H "Content-Type: application/json" \
	-d '{"enabled":false}'
}
 
enable_speakerOnly() {
local speaker_id="$1"
  curl -X PATCH "${BASE_URL}/speakers/${speaker_id}" \
    -H "Authorization: Bearer ${authTOKEN}" \
    -H "Content-Type: application/json" \
	-d '{"enabled":true}'
}
 
list_speakersGroup() {
  curl -X GET "${BASE_URL}/speakerGroups/7d607f3d-8c2f-461a-9872-XXXXXX/speakers?disabled" \
    -H "Authorization: Bearer ${authTOKEN}" \
    -H "Content-Type: application/json"
}
 
# this worked:  disableing Speaker ID: 26edf44e-d5e8-46d6-b9eb-XXX
 
getAuthToken
 
json_data=$(list_speakersGroup)		# Get the JSON data
 
speaker_ids=$(echo "$json_data" | jq -r '.array[].id')	# Extract the speaker IDs using jq
 
# for speaker_id in $speaker_ids; do
  # echo "Enabling Speaker ID: $speaker_id"
# done
 
 
# Check the action and run the corresponding function
if [ "$ACTION" == "enable" ]; then
	echo "-------- enable RUNNING"
		for speaker_id in $speaker_ids; do
		  echo "Enabling Speaker ID: $speaker_id"
		  enable_speakerOnly "$speaker_id"
		done
	sleep 5
	play_sound_alert
 
elif [ "$ACTION" == "disable" ]; then
	echo "-------- disable RUNNING"
	sleep 5
	play_sound_alert
		for speaker_id in $speaker_ids; do
		  echo "disableing Speaker ID: $speaker_id"
		  disable_speakerOnly "$speaker_id"
		done
else
  echo "Invalid action. Usage: $0 {enable|disable}"
  exit 1
fi

thanks

Thank you for sharing your workaround!

I will ask Milestone Development to get the information into the Rest API documentation. I have to agree that it belongs there.

I will mention this forum thread to Milestone Product Management that they can consider to prioritize the missing pieces in support for Rules.

Thank you for having the same issue and provided the reason why some of the rules aren’t supported.

I have the same issue, where my rules is when the event is triggered, the action will be setMatrixView to one of the Matrix to display the live camera view.

I was trying to update this rules whenever I received an alert from 3rd alarm system, then I will update the value of matrix to the responsible PC and set the correct live camera to display the live view. Then, trigger the event so the rules can do my job without setting many rules in Milestone to fulfill my client’s requirement.

With this, any idea on how can I have another work around with update the rule? Much appreciated if you can provide the information. Many thanks!

Matrix is different in that it is supported. Introduced in 2023 R3. (I hope you can upgrade your version.)

Ref. https://doc.developer.milestonesys.com/html/index.html?base=gettingstarted/intro_configurationapi.html&tree=tree_4.html

Also, if you configure a rule that uses “the devices from metadata” and then trigger it with an analytics event, where the source is the camera you want to show, you do not have to create a new rule for every camera.. (But you will need a rule for each Matrix.)

PS. If you have more questions to this please create a new question here on the forum..

Also, I am running under 2023 R1 version.