Chapter 7. Sending HTTP Requests—The Simple Way

HelloPachube in Chapter 6 is so simple because the Gsiot.PachubeClient library is built for the single purpose of pushing samples to Pachube. It completely hides the .NET classes needed to implement an HTTP client. If you want to use Pachube in a different way, or if you want to write clients for other services, you can use the more general HttpWebRequest and HttpWebResponse classes, which are located in the System.Net namespace.

SimplePutRequest

Example 7-1 shows how these classes can be used to send a single sample to Pachube.

Example 7-1. SimplePutRequest
using System.IO; using System.Net; using System.Text; using Microsoft.SPOT; public class SimplePutRequest { public static void Main() { const string ...

Get Getting Started with the Internet of Things now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.