400 error using Events REST API

Hi,

I am using the Events REST API and have been able to use it to retrieve analytics and user defined events, as well as list all events. But when I try to create an event, I get a 400 error.

The data structure I am using is like this:

{

“type”: “8edff7b3-0f7d-4010-ad90-450ef8ff8bee”,

“source”: “cameras/e135a4c5-0b9d-473d-ac1c-517141d39f0b”,

“time”: “2023-09-29T10:05:23Z”,

“datatype”: “analytics”,

“data”: {}

}

The camera GUID is valid (I’ve used it successfully as the ID in the SOAP equivalent). For “type” I’m using the GUID for the analytics event I searched for.

Any help would be appreciated.

Thanks

What kind of event are you trying to POST?

If you use “datatype”: “analytics”, then you need to pass an analytics data object like shown in the docs. Milestone XProtect Events API Reference (milestonesys.com)

You can also trigger events without data (using datatype: “none”).

Got it. Thanks. I had not noticed that I could expand that section. Got it working.

The doc should perhaps be updated to say that data.startTime and endTime are mandatory.