0

I'm trying to send an http POST request from my netduino, I've been on the netduino forum and there is conflicting reports of this being able to work, the exception occurs on the first line

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("example.com:8080");

            string postData = "temperature=" + tempSensor.Temperature;
            byte[] data = Encoding.UTF8.GetBytes(postData);

            request.Method = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = data.Length;

            using (Stream stream = request.GetRequestStream())
            {
                for (int i = 0; i < 10; i++)
                {
                    stream.Write(data, 0, data.Length);
                    Thread.Sleep(1000);
                }
            }

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            Debug.Print(response.StatusDescription);
Jacob
  • 86
  • 3
  • 9

1 Answers1

0

In your call to .Create(...) method, either pass an instance of Uri or include protoctol, i.e. http://example.com:8080.

THX-1138
  • 21,316
  • 26
  • 96
  • 160