How create Event through APIs and execute them.
AnsweredHi,
I am trying to integrate Event rule Email notification into our Application through API calling. I want to create an event that will send a notification to the user if motion is detected in any Camera.
Note: I will send an Email address through API on which all notifications will be sent.
Can you please explain how I can create Events and execute them. Do I have to add scheduler at our backend or Event will automatically send Email if motion is detected in any Camera?
Thanks in advance
-
Hello Vishal,
You can create an event rule by calling /ec2/saveEventRule method.
You can call /ec2/getEventRules for getting example of values to be filled in /ec2/saveEventRule
Here is a JSON of the example rule for an event triggered when motion is detected - "eventType": "cameraMotionEvent" - on a camera with ID {ed93120e-0f50-3cdf-39c8-dd52a640688c}. The Server sends an email "eventType": "cameraMotionEvent",
{
"actionParams": "{\"allUsers\":false,\"authType\":\"authBasicAndDigest\",\"durationMs\":5000,\"forced\":true,\"fps\":10,\"needConfirmation\":false,\"playToClient\":true,\"recordAfter\":0,\"recordBeforeMs\":1000,\"requestType\":\"\",\"streamQuality\":\"highest\",\"useSource\":false}",
"actionResourceIds": [
"{00000000-0000-0000-0000-100000000001}"
],
"actionType": "sendMailAction",
"aggregationPeriod": 60,
"comment": "",
"disabled": false,
"eventCondition": "{\"eventTimestampUsec\":\"0\",\"eventType\":\"undefinedEvent\",\"metadata\":{\"allUsers\":false,\"level\":\"0\"},\"omitDbLogging\":false,\"reasonCode\":\"none\"}",
"eventResourceIds": [
"{ed93120e-0f50-3cdf-39c8-dd52a640688c}"
],
"eventState": "Active",
"eventType": "cameraMotionEvent",
"id": "{e8546d41-3d8b-4bbc-9c31-b58bfa7f627a}",
"schedule": "",
"system": false
}You can refer built-in API documentation in server web interface.
http://localhost:7001/static/index.html#/developers
0 -
Thanks,
I will try this method. One last query can I also set up email through APIs on which all the notification will be received
0 -
As you can see there is actionResourceIds field, which in this case contains id of user roles or user accounts the email notification will be sent to. Email address is a property of the user account.
You cant change email of user account by calling /ec2/saveUser API method.
0 -
Andrey Terentyev I tried creating Event rule using above JSON but get unauthorized error although I have Administrative Unrestricted of the account also can you please mention about id as nothing is mentioned about this in the documentation.
0 -
Andrey Terentyev Now I am able to create Event rule through digest authentication but not through the API authentication token as mentioned in docs.
Again Thanks for your support.
0 -
Vishal, are you generating Authentication token using 'GET' or 'POST'?
When you create a rule, you send POST request, so it needs special authentication token.
0 -
Thanks, Andrey Terentyev @...
Earlier I was using previously generated GET authentication token but after using the POST method I was able to use the events through APIs.
0
Please sign in to leave a comment.
Comments
7 comments