Hi.
I added some user-defined events with some rules and I tried to manipulate them using REST API. I found EventsRestApiPython example and I was able to successfully trigger my user-defined event and also saw them appear in server logs.
However, when I try to read all the events and use GET api/rest/v1/events I receive a list of 10 events, with timestamp. However the events that I triggered are not there and all the time I receive same events ids and same timestamps (no events from this day, for example). What am I doing wrong? Am I sending wrong commands or am I not able to see list of this events?
I am accessing as user that has administrator rights.
In order to see events this way the events need to be saved.
Please check in the Management Client → Tools → Options, the Alarms and Events tab, under Event retention find External Events. If it is set to 0 (zero) the user-defined events will not be saved at all, if this is the case adjust the settings.
A word of caution, if you set up too long retention and the VMS saves too many events you can cause the SQL Server database to overfill.
Thank you for answer.
I have External Events time set to 1. In the meantime I found out that in example code from github searching was made with api/rest/v1/events?page=0&size=10&include=data and that page=0 was the reason why I didn’t get latest events.
Thank you for the feedback. The way I understand it you are able to move on, but I will ask ask the team here at Milestone if the sample might need a looking into.
Yes, but for some reason I am unable to see newest events in that setup.
When I use get/events I don’t see latest event I got stuck on same event every time. When I use events/?page=0&size=10&include=data still the same result. Only when I was changing the page property to page=1 or some other number I got different results and I was able to see later events and I don’t know why is this functioning this way.
Also, when I want to filter events by id and using events/{id} I also got stuck getting same event even though that same event happened after that time. I am able to filter that event in my code, so I can bypass this problem, but I don’t know why this isn’t working as I expected, it would be much easier for me.
Thank you @Bo Ellegård Andersen (Milestone Systems) .
Maybe if you want to newest events you can use the ‘orderBy’..
../api/rest/v1/events?orderBy=desc:‘time’
(or
../api/rest/v1/events?orderBy=desc:‘time’&page=0&size=10
/api/rest/v1/events/?orderBy=desc:‘time’&page=0&size=10&source.id=equals:‘61999aae-19b3-4539-b319-ca8d4c12725a’
)
I have experimented with the paging, and I was unable to see anything wrong. If you believe something is not working correctly could you please elaborate?
Hi @Bo Ellegård Andersen (Milestone Systems)
Thank you for your answer and sorry for late response, I was out of office.
I am trying to read last events and sometimes I just fail to get newest.
For example I was using in my code api/rest/v1/events to get all events and then see the latest and after some time I was not able to get new events (I keep getting same event every time as last event even though there are more events that occured later). However, when I enter, for example, liike you wrote ../api/rest/v1/events?orderBy=desc:‘time’&page=1 I get latest result. I tried api/rest/v1/events?orderBy=desc:‘time’ but I also did not get latest result. So I am not sure why is this happening or do you have any idea what can cause this problem?
To me it looks like api/rest/v1/events returns first x events and after that it stops. Is this how it is supposed to work?
I can’t figure how it fails for you, or if it even fails
I think that you might instead interested in subscribing to events as they happen. If that is true then please have a look at the Events and State WebSocket API
https://doc.developer.milestonesys.com/mipvmsapi/api/events-ws/v1/
and samples
https://doc.developer.milestonesys.com/html/index.html?base=samples/protocolsamples/eventsandstatewebsocketapipython/readme.html&tree=tree_3.html
https://doc.developer.milestonesys.com/html/index.html?base=samples/componentsamples/eventandstateviewer/readme.html&tree=tree_2.html
If you truly have more events, within the retention that is setup, than what you get, it must be an issue that I cannot reproduce.
If you use ‘page’ I suppose the result you get will depend on ‘size’.
https://doc.developer.milestonesys.com/mipvmsapi/api/events-rest/v1/#tag/Events/operation/Events_Get
I wonder when you use paging I don’t suppose it will take on the newest events as it is another request on an old request. I hope this is making sense. You make a request and then several more moving through the pages, and if new events were added to the list the paging would go haywire.
If you think something is wrong, I think I need you to describe in greater detail what you do and what you observe.
Yes, I am also interested in subscribing so I can also try WebSocket API, thank you. And yes, you are right, if I use /page then I can show number of events dependent of size and it makes sense that I would need to change page for new events.
I still have no idea why after some time api/events sometimes stops to give me latest answer, but if I manage to see something like that again with other requests I will send you more detailed information and screenshots.
Thank you Bo for answers and suggestions.