HTTP Notifications

The InControl notifications include the ability to send notifications via HTTP post. There’s very little information about how this post works. For example, the popup help says “The POST data is an array of events in JSON format”. Post data is normally name/value pairs. Is there a named post parameter that contains this json? What would the json for different kinds of notifications look like?

It appears that the test button merely pings the URL and does not send data.

1 Like

Never mind, I figured out how to access the raw data. For anybody else trying to do this in .net, this worked:

    public ActionResult Index()
    {
        Request.InputStream.Seek(0, SeekOrigin.Begin);
        var json = new StreamReader(Request.InputStream).ReadToEnd();
        var alerts = JsonConvert.DeserializeObject<List<PeplinkNotification>>(json);
        foreach (var a in alerts)
        {
            var time = DateTime.MaxValue;
            DateTime.TryParse(a.ts, out time);
            var message = $"\"{a.client_name}\" reported \"{a.detail}\". " +
                          $"{(time != DateTime.MaxValue ? time.ToString("G") : "")}";
            _[send or log the message with whatever means you have]_
        }
        return Content("OK");
    }

    public class PeplinkNotification
    {
        public string ts { get; set; }
        public string device_name { get; set; }
        public string device_id { get; set; }
        public string client_name { get; set; }
        public string client_mac { get; set; }
        public string event_type { get; set; }
        public string detail { get; set; }
        public string longitude { get; set; }
        public string latitude { get; set; }
        public string gps_timestamp { get; set; }
        public string sn { get; set; }
    }