protected override void Execute(CodeActivityContext context) { var chID = Channel__ID.Get(context); var readKey = Read_API_Key.Get(context) == null ? "" : "api_key=" + Read_API_Key.Get(context); var chosenFormat = Format.ToString(); var chosenField = (FieldNumber.GetHashCode() + 1).ToString(); var results = Results.Get(context) == 0 ? "" : "&results=" + Results.Get(context).ToString(); var days = Days.Get(context) == 0 ? "" : "&days=" + Days.Get(context).ToString(); var minutes = Minutes.Get(context) == 0 ? "" : "&minutes=" + Minutes.Get(context).ToString(); var start = Start.Get(context) == null ? "" : "&start=" + Start.Get(context); var end = End.Get(context) == null ? "" : "&end=" + End.Get(context); var timezone = Timezone.Get(context) == null ? "" : "&timezone=" + Timezone.Get(context); var offset = Offset.Get(context) == 0 ? "" : "&offset=" + Offset.Get(context).ToString(); var status = Status.Get(context) == true ? "&status=true" : ""; var metadata = Metadata.Get(context) == true ? "&metadata=true" : ""; var location = Location.Get(context) == true ? "&location=true" : ""; var min = Min.Get(context) == 0 ? "" : "&min=" + Min.Get(context).ToString(); var max = Max.Get(context) == 0 ? "" : "&max=" + Max.Get(context).ToString(); var round = Round.Get(context) == 0 ? "" : "&round=" + Round.Get(context).ToString(); var timescale = Timescale.Get(context) == null ? "" : "×cale=" + Timescale.Get(context); var sum = Sum.Get(context) == null ? "" : "&sum=" + Sum.Get(context); var average = Average.Get(context) == null ? "" : "&average=" + Average.Get(context); var median = Median.Get(context) == null ? "" : "&median=" + Median.Get(context); var callback = Callback.Get(context) == null ? "" : "&callback=" + Callback.Get(context); string URL = "https://api.thingspeak.com/channels/" + chID + "/fields/" + chosenField + "." + chosenFormat + "?"; URL = URL + readKey + results + days + minutes + start + end + timezone + offset + status + metadata + location + min + max + round + timescale + sum + average + median + callback; WebRequest wrGETURL = WebRequest.Create(URL); Stream objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); 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); }