Enable / Disable Mobile notification rule via API issue

Answered

Comments

11 comments

  • Avatar
    Andrey Terentyev

    Hello,

    Please provide the following info: OS version, VMS build number, the code example you're operating with.

    0
    Comment actions Permalink
  • Avatar
    Max Taiani

    Hi Andrey,

    Information updated for software versions etc…

    Attached code used:

    (Fails enable rule)



    {
    "actionParams": "{\"additionalResources\":[\"{00000000-0000-0000-0000-100000000000}\",\"{00000000-0000-0000-0000-100000000001}\"],\"allUsers\":false,\"authType\":\"authBasicAndDigest\",\"durationMs\":5000,\"forced\":true,\"fps\":10,\"needConfirmation\":false,\"playToClient\":true,\"recordAfter\":0,\"recordBeforeMs\":1000,\"streamQuality\":\"highest\",\"useSource\":true}",
    "actionResourceIds": [],
    "actionType": "pushNotificationAction",
    "aggregationPeriod": 0,
    "comment": "Mobile App Cam 04",
    "disabled": false,
    "eventCondition": "{\"analyticsEngineId\":\"{9537fc21-e0b1-3ca8-424f-385cf4e9a45a}\",\"eventTimestampUsec\":\"0\",\"eventType\":\"undefinedEvent\",\"inputPortId\":\"nx.openvino_object_detection.areaEntranceDetected\",\"metadata\":{\"allUsers\":false,\"level\":\"\"},\"omitDbLogging\":false,\"progress\":0,\"reasonCode\":\"none\"}",
    "eventResourceIds": [
    "{28ad2da1-6101-563e-f416-16881ca47591}"
    ],
    "eventState": "Undefined",
    "eventType": "analyticsSdkEvent",
    "id": "{1e91c869-d794-44de-a10f-d40af1b456cc}",
    "schedule": "",
    "system": false
    }

    (This rule disabled works correctly)

    disabled:



    {
    "actionParams": "{\"additionalResources\":[\"{00000000-0000-0000-0000-100000000000}\",\"{00000000-0000-0000-0000-100000000001}\"],\"allUsers\":false,\"authType\":\"authBasicAndDigest\",\"durationMs\":5000,\"forced\":true,\"fps\":10,\"needConfirmation\":false,\"playToClient\":true,\"recordAfter\":0,\"recordBeforeMs\":1000,\"streamQuality\":\"highest\",\"useSource\":true}",
    "actionResourceIds": [],
    "actionType": "pushNotificationAction",
    "aggregationPeriod": 0,
    "comment": "Mobile App Cam 04",
    "disabled": true,
    "eventCondition": "{\"analyticsEngineId\":\"{9537fc21-e0b1-3ca8-424f-385cf4e9a45a}\",\"eventTimestampUsec\":\"0\",\"eventType\":\"undefinedEvent\",\"inputPortId\":\"nx.openvino_object_detection.areaEntranceDetected\",\"metadata\":{\"allUsers\":false,\"level\":\"\"},\"omitDbLogging\":false,\"progress\":0,\"reasonCode\":\"none\"}",
    "eventResourceIds": [
    "{28ad2da1-6101-563e-f416-16881ca47591}"
    ],
    "eventState": "Undefined",
    "eventType": "analyticsSdkEvent",
    "id": "{1e91c869-d794-44de-a10f-d40af1b456cc}",
    "schedule": "",
    "system": false
    }

    I can manually call the API via a browser session and can see NX picking it up as I get a notification on the client weather its enabled or disabled.

    0
    Comment actions Permalink
  • Avatar
    Andrew Sharrem

    Unofficially: to enable / disable a rule via API, you only need the ID & disabled state in the JSON data, not all the other guff ;-)

    {
      "id": "0f148ab8-45ce-43fa-948b-54be268853d0",
      "disabled": true
    }
     
    Hope it helps.
    0
    Comment actions Permalink
  • Avatar
    Max Taiani

    Hi Andrew,

    I have given this ago. The problem is still present. I can disable the rule with no issue based on the updated JSON template you provided above. Enabling does not seem to work. Everything is identical apart from the variable where ("disabled": false) is used.

     

    Any idea?

     

    This works:

    {

    "id": "1e91c869-d794-44de-a10f-d40af1b456cc",

    "disabled": true

    }

     

    This doesn't work:

     

    {

    "id": "1e91c869-d794-44de-a10f-d40af1b456cc",

    "disabled": false

    }

     

    0
    Comment actions Permalink
  • Avatar
    Andrew Sharrem

    I would suggest your "Enable" trigger method (Generic event) is the likely issue then.

    Change your "Enable" trigger event to debug the issue. Perhaps try a soft trigger to start with, or change the action to "write to log" to make sure your event is actually working.

    0
    Comment actions Permalink
  • Avatar
    Max Taiani

    Hi Andrew,

    I amended to the rule to "write to log" and can confirm my "Enable" trigger event is working correctly. As soon as I change this back to enable the camera rule. This still fails to work. I'm quite sure my enable trigger method isn't at fault here.

    What do you suggest I could try next?

    0
    Comment actions Permalink
  • Avatar
    Andrew Sharrem

    Hmmm...Interesting.

    I don't work for Nx, but I am intrigued by the issue.
     
    I'm happy to cast my eye over your system prior to you raising a support ticket via your nx distributor.
    You can email me privately at nx@nfs.co.nz and we can arrange some sort of remote session.
     
    Regards,
    Andrew Sharrem
    0
    Comment actions Permalink
  • Avatar
    Andrew Sharrem

    This is my enable rule working fine...as does the corresponding disable rule.

    0
    Comment actions Permalink
  • Avatar
    Max Taiani

    I can successfully enable the rule via a soft trigger with no issue there, like your example above!

    I can't exactly pinpoint where this is breaking as its pretty much identical to my disable API call / rule which works. Its likely that I have missed something small which I just cannot see ;)

    My URL API call is as followed: XXX.XXX.XXX.XXX:7001/api/createEvent?source=Analytic+Enabled+&caption=Analytic+Enabled&description=Analytic+Enabled

     

     

    0
    Comment actions Permalink
  • Avatar
    Andrew Sharrem

    Since the soft trigger works, it is definately your generic event.

    The rules engine works sequentially & matches any keywords - seperated by spaces. My bet is the "disable" event rule is after the "enable" event rule, therefore is also triggering, i.e. both rules are matching in sequence on the word "Analytic".

    Use an underscore "_" instead of space for the keyword (everywhere) to create an exact match.
    I.e. Analytic_Enable

    Regards,
    Andy ;-)

    0
    Comment actions Permalink
  • Avatar
    Max Taiani

    Hi Andy,

     

    I tried tried using an underscore and this didn't work for both enabling & disabling. I did try to break it up as I have a feeling you were on the right track where the rule was disabling after enabling. If I were to refresh the URL is would randomly work and then stop.

     

    My solution to breaking it up is by doing the following and seems to be working each time. :)

    0
    Comment actions Permalink

Please sign in to leave a comment.