Trigger HTTP Request with script

  • 142 Views
  • Last Post 13 November 2014
miguelparada@gmail.com posted this 13 November 2014

Thanks for the quick reply!

Got the HTTP request working, now I can build up external stuff and also integrate with Prowl for push notifications.

Order By: Standard | Newest | Votes
Ryan-Scott posted this 13 November 2014


I am not familiar with C# so I was wondering if there is a way that I can generate a HTTP GET or POST request with a script to an external resource that way I can write a Rest API in python to add functionality to my setup.

This is so far what I'm trying out. Thanks!!

using System;
using System.Collections.Generic;
using System.Text;
using MLS.ZWave.Service.Rules;
using MLS.ZWave.BusinessObjects;
using System.Net;


public class MyScript : ScriptBase, ScriptInterface {


public void runScript() {
try {

System.Net.WebRequest request = WebRequest.Create(url);

} catch (Exception ex) {
// Log the exception here
var message = ex.Message;
}
}
}


Yes, there's a way:


using (var c = new WebClient()) {
c.Headers.Add("Content-Type", "Some content Type");
var stringResult = c.UploadString("http://somewhere.com", "POST", body);
}


You can also do this in a scene itself if you are on the latest version of InControl. Instead of the "Add Device" button, you click the arrow next to it and choose to "Add HTTP Command" - this gives you quite a bit of control as well.

miguelparada@gmail.com posted this 13 November 2014

Thanks for the quick reply!

Got the HTTP request working, now I can build up external stuff and also integrate with Prowl for push notifications.

Close