0

I have Netduino Plus and I need it to send Http requests to my server. I'm not a guru in C#, I've never tried it before, so I copy/paste code from internet and try to make it works. But even after several hours I can't get it work.

using System; using System.IO; using System.Net; using System.Text; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace NetduinoPlusApplication5 { public class Program { static void Main() { var request = WebRequest.Create("http://example.com?variable=1"); request.Method = "GET"; var result = request.GetResponse(); } } } 

What am I doing wrong?

3
  • You forgot to tell us what the problem is. Commented Nov 21, 2014 at 17:34
  • It doesn't work. That's the problem :( Commented Nov 21, 2014 at 18:27
  • That's a useless description of the problem. If you call a mechanic and tell him/her your car "doesn't work", they'll hang up on you. What is the specific problem? Are you getting an exception? Commented Nov 21, 2014 at 19:32

1 Answer 1

1

You are executing a GET request so I think you want to get the response body from the server. In this case you have to use :

Stream respStream = resp.GetResponseStream();

instead of simple GetResponse(). In this way, you can read on the stream the response body.

Paolo.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.