• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Mango REST API -- event detectors

    User help
    mangoapi api rest api event-detectors
    3
    7
    3.0k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      silvia
      last edited by

      Re: How do I create event detectors using the Mango API?

      Hi all,

      I see that event-detectors is now part of the API :)

      I'm trying to create multiple event detectors for the same multi-state data point; is that possible to do in one single step?

      At the moment I'm trying to do a single event detector using the POST method through the API and using this code (obtained via GET for another data point, and changing the xid, dataSourceId and dataPointId) -- it doesn't work, though, and I get an error 500 back.

          {
                "xid":          "socket_2026-vacant",
                "name":         "Socket 2026 is vacant",
                "duration":       0,
                "durationType":     "SECONDS",
                "alarmLevel":       "INFORMATION",
                "supportedDataTypes": [
                    "MULTISTATE"
                ],
      
                "description":      "Socket 2026 is vacant",
                "alias":            "Socket 2026 is vacant",
                "eventType": {
                  "dataSourceId":     229,
                  "dataPointId":      400,
                  "duplicateHandling":  "IGNORE",
                  "typeName":        "DATA_POINT",
                  "rateLimited":      false
                },
      
                "rtnApplicable":        true,
                "detectorSourceType":   "DATA_POINT",
                "validationMessages":   [],
                "detectorType":         "MULTISTATE_STATE"              
              }
      

      I want these event detectors to be created immediately after the data points are created, so I'm using response.data.id and response.data.dataSourceId to get this info.

      I would think that these two ids are enough to link the event detector with the data point? What am I doing wrong here? And can I create multiple event detectors at once?

      Thanks and sorry for so many questions ^^U

      Silvia

      1 Reply Last reply Reply Quote 0
      • Jared WiltshireJ
        Jared Wiltshire
        last edited by

        @silvia Have you checked the response from the API in the developer tools? There should be an error message.

        I have used the API to create high/low limit event detectors posting something like this

        {
            "xid": "",
            "name": "",
            "limit": 1500,
            "resetLimit": 0,
            "notHigher": false,
            "useResetLimit": false,
            "duration": 60,
            "durationType": "SECONDS",
            "alarmLevel": "WARNING",
            "supportedDataTypes": [
                "NUMERIC"
            ],
            "alias": "",
            "detectorSourceType": "DATA_POINT",
            "sourceId": 123,
            "rtnApplicable": true,
            "validationMessages": [],
            "detectorType": "HIGH_LIMIT"
        }
        

        Try removing the eventType property. Also try without an XID and name.

        Developer at Radix IoT

        1 Reply Last reply Reply Quote 0
        • phildunlapP
          phildunlap
          last edited by

          Silvia,

          One option for doing large configuration additions/changes is to use the /rest/v2/json-emport endpoints. Data points have an array of event detectors (like in the regular import/export, though that may change and even detectors may move into their own array) and very large configurations can be submitted for import at once.

          1 Reply Last reply Reply Quote 0
          • S
            silvia
            last edited by

            @Jared-Wiltshire, @phildunlap, thanks for your answers. Because I'm trying to create 5 events for each data point, it'd rather do it in bulk importing the JSON.

            I can easily import using the 'Import' tab.

            0_1510737986128_mango.JPG

            However, if I try to do the same through the API (either using POST /v1/json-emport or /v1/json-emport/upload-file), I get error 202 - no content.

            0_1510738898742_mango2.JPG

            These are the response headers:

            {
              "Location": "http://192.168.100.254:8080/rest/v1/json-emport/import/IMPORT_e85e1010-ed81-46c3-bc02-2a24637e1065",
              "Date": "Wed, 15 Nov 2017 09:33:46 GMT",
              "Cache-Control": "no-cache, no-store, max-age=0, must-revalidate",
              "X-Content-Type-Options": "nosniff",
              "X-Frame-Options": "SAMEORIGIN",
              "Content-Length": "0",
              "X-Xss-Protection": "1; mode=block"
            }
            

            I've also tried removing the outer object and the "dataPoints" array, so that the body only contains the data point object. Regarding the timezone, I'm setting it to either blank, '+00:00' or 'Europe/London', as another post suggested checking here for valid timezones: http://joda-time.sourceforge.net/timezones.html.

            Any new ideas please? Thanks :)

            1 Reply Last reply Reply Quote 0
            • phildunlapP
              phildunlap
              last edited by phildunlap

              Hi Silvia,

              I believe you've posted a response to a successful request. Because these imports could be very large, they could take a long time, and thus the response to the submission of an import is better fast, with a Location header you can GET for information on how the import task is progressing.

              1 Reply Last reply Reply Quote 0
              • Jared WiltshireJ
                Jared Wiltshire
                last edited by

                As Phillip said HTTP 202 (Accecpted) is a successful response indicating that the import has started.

                Developer at Radix IoT

                1 Reply Last reply Reply Quote 0
                • S
                  silvia
                  last edited by

                  You're both absolutely right, maybe I wasn't refreshing the page to see the newly created events, I can now... Thanks so much for all of your help! :)

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post