How create Event through APIs and execute them.

Answered

Comments

7 comments

  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Vishal Yadav

    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
    Comment actions Permalink
  • Avatar
    Andrey Terentyev

    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
    Comment actions Permalink
  • Avatar
    Vishal Yadav

    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
    Comment actions Permalink
  • Avatar
    Vishal Yadav

    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
    Comment actions Permalink
  • Avatar
    Nx Support

    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
    Comment actions Permalink
  • Avatar
    Vishal Yadav

    Thanks, Andrey Terentyev  Nx Support

    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
    Comment actions Permalink

Please sign in to leave a comment.