Question

Veeam Service Provider Console rest api get active alarms


Hi,

I'd like to know what I'm doing wrong so I can't successfully make an api call to VSPC (7.0.0.12777) in order to return the active alarms.

This is what I'm trying to do:

url = f'{base_path}/alarms/active'

params = {

            "filter": "[{\"operation\":\"or\",\"items\": \                       [{\"property\":\"lastActivation.status\",\"operation\":\"equals\",\"collation\":\"ignorecase\",\"value\":\"warning\"},\        {\"property\":\"lastActivation.status\",\"operation\":\"equals\",\"collation\":\"ignorecase\",\"value\":\"error\"}] \
 }]",

            "sort": "[{\"property\":\"lastActivation.time\", \"direction\":\"descending\"}]"

        }
r = session.get(url, params=params)

 
the error I have -- "message":"Value cannot be null.\\r\\nParameter name: source","type":"unspecified","code":500
 


7 comments

Userlevel 6
Badge +5

Hi Peter,

Which programming language are you using?

Here’s a PowerShell example where I have a filter similar to yours. Given the error code, my guess is your params variable is not parsing properly or your REST client is not encoding your request.

Hope this helps!

Hi Chris, thanks for your reply
i'm using python and i tested the powershell example you indicated (of course i had to change powershell to python)

line 268 & 269 it will become this:

filter_criteria = [{

    "operation": "or",

    "items": [

       {

            "property": "internalId",

            "operation": "equals",

            "value": 17

       },

       {

            "property": "internalId",

            "operation": "equals",

            "value": 41

       }

    ]

}]

 

url = f"{base_path}/alarms/templates"

params = {

            "filter": json.dumps(filter_criteria)

        }

r = session.get(url, params=params)

alarmUids = r.json().get('data')


this works and I get results but when I try to execute lines 272 and 273 (in python) the errors start
 

filter_criteria = [{

    "property": "alarmTemplateUid",

    "operation": "equals",

    "value": alarmUids[0]['instanceUid']

}]

 

url = f"{base_path}alarms/active"

params = {

            "filter": json.dumps(filter_criteria)

        }

r = session.get(url, params=params)


this get me a response  with status code 404 , technically this isn't an error, it just indicates that I'm querying for something that doesn't exist
 

404

Requested resource does not exist.

message property of an error response contains the name of the missing resource.

Userlevel 4
Badge +2

Maybe a dumb suggestion (i dont really work with python), but can you export the payload that is created by your python script to check if there are no errors in the payload? Like Chris already suggested, its probably a payload issue.

Userlevel 6
Badge +5

Here’s a working Python sample that I just tested in my lab. I hope this points you in the right direction.

I generated this sample using Postman. 😁

import requests

url = "https://vspc.contoso.local:1280/api/v3/alarms/active?filter=[{'property':'alarmTemplateUid','operation':'equals','value':'364787c6-42bc-4c48-a2fa-88fa3ab60a62'}]"

payload = {}
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
}

response = requests.request("GET", url, headers=headers, data=payload)

print(response.text)

 

Userlevel 4
Badge +2

I think you are missing a backslash before alarms

you state the variable base_path but I don’t see a backslash between that variable and the endpoint alarms.


edit: to make my point more clear.
You first snippit that works is:

url = f"{base_path}/alarms/templates"

the second snippit that doesnt:
url = f"{base_path}alarms/active"

Userlevel 7
Badge +7

Hi @PeterDu ,

you can find examples of several languages in the official API Reference, including Python..hope can help!

https://helpcenter.veeam.com/docs/vac/rest/reference/vspc-rest.html?ver=80#tag/Alarms/operation/GetActiveAlarms

Hello, everyone,

I've been creating a lab to test my problem and as expected everything went successfully.
The script I had to monitor the VSPC is working now my problem is to understand why it is not working in the production environment. (The script was working in production and from one moment to the next it stopped working that's when I came to the community for help).

I've now asked the company's Veeam SME to validate the situation and if the problem persists we'll have to open a case with Veeam.

Thanks to everyone who helped with their ideas/opinions

just one note:
@Epicfailing you were right, the example I posted was missing a backslash

Comment