protected override void Execute(CodeActivityContext context) { //Channel Details var writeKey = Write_API_Key.Get(context); //Field Values var f1 = Field1.Get(context) != null ? "&field1=" + Field1.Get(context) : ""; var f2 = Field2.Get(context) != null ? "&field2=" + Field2.Get(context) : ""; var f3 = Field3.Get(context) != null ? "&field3=" + Field3.Get(context) : ""; var f4 = Field4.Get(context) != null ? "&field4=" + Field4.Get(context) : ""; var f5 = Field5.Get(context) != null ? "&field5=" + Field5.Get(context) : ""; var f6 = Field6.Get(context) != null ? "&field6=" + Field6.Get(context) : ""; var f7 = Field7.Get(context) != null ? "&field7=" + Field7.Get(context) : ""; var f8 = Field8.Get(context) != null ? "&field8=" + Field8.Get(context) : ""; var chosenFormat = Format.GetHashCode() == 0 ? "" : "." + Format.ToString(); //Optional Parameters var lat = Lat.Get(context) == 0 ? "" : "&lat=" + Lat.Get(context).ToString(); var lon = Long.Get(context) == 0 ? "" : "&long=" + Long.Get(context).ToString(); var elevation = Elevation.Get(context) == 0 ? "" : "&elevation=" + Elevation.Get(context).ToString(); var status = Status.Get(context) == null ? "" : "&status=" + Status.Get(context); var twitter = Twitter.Get(context) == null ? "" : "&twitter=" + Twitter.Get(context); var tweet = Tweet.Get(context) == null ? "" : "&tweet=" + Tweet.Get(context); var created_at = Created_at.Get(context) == null ? "" : "&created_at=" + Created_at.Get(context); //Http Request URL string URL = "https://api.thingspeak.com/update" + chosenFormat + "?api_key=" + writeKey; URL = URL + f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + lat + lon + elevation + status + twitter + tweet + created_at; //Creating GET Http Request WebRequest wrGETURL = WebRequest.Create(URL); Stream objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); //Capturing the response string sLine = ""; string httpResponse = ""; while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null) { httpResponse = httpResponse + sLine + "\n"; } } objStream.Close(); //objReader.Close(); Response.Set(context, httpResponse); }