Requesting URL with FEZ Panda II with connect shield

Hello guys,

For my school project i need to insert sensor data from my FEZ Panda in a MySQL database.
I think the best way is to make a script which reads GET data so in my Panda application i have to request a certain URL.
For example: thisistheurl.com/addSensordata.php?height=12&tilt=24

For some reason i can’t get this to work and i’m desperate since i have to demonstrate this tomorrow.

Can somebody help me?

Kind regards,

Marco

Why are you GETing data instead of POSTing data? Show us some code and tell us more about your exact problem.

Welcome to the forums Marco.

As Ian points out, telling us more about what you want to do will help here. Telling us how your code doesn’t work today and what you want to do with it, including who is doing the pull/push of data and to what is critical.

If you have Fez Panda and Connect shield, then there’s good examples of returning values from Fez sensors or data (look at several of the code submissions by Jasdev or Nicolas3 of a server instance that works great) and there’s examples of pushing data to Pachube (or whatever they call themselves these days), again that might help you frame your problem statement.

@ MarcoV
It sounds like you want to transfer sensor data from your Panda II to a web server using a Get request. If you are using a Panda and the Connect shield, you need to use the GHIElectronics.NETMF.Net library. You will also need to use the HttpWebRequest class to do the Get request to the web server.

Try doing a search like this and see if you can find an answer to your problem: http://www.tinyclr.com/forum/search?q=HttpWebRequest

Like Ian and Brett said, we need to see some code and an explanation of where it is not working in order to help.

Each post gives more and more info … So I figured, just give him the fish :slight_smile:


var req = System.Net.HttpWebRequest.Create("http://www.myUrl.com/GetVar1=Value&GetVar2=Value&GetVar3=Value");
var response = req.GetResponse();
// this reads the response from the webserver -- optional
var reader = new System.IO.StreamReader(response.GetResponseStream());
var responseText = reader.ReadToEnd();

@ ianlee74 - sometimes when you want to do something quick and easy as proof of concept, GET works just fine.


var request = System.Net.HttpWebRequest.Create("http://www.myUrl.com");           
string postData = "Var1=value&Var2=value&Var3=value";

byte[] data = System.Text.Encoding.UTF8.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
var requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);

var response = request.GetResponse();

// this reads the response from the webserver -- optional
var reader = new System.IO.StreamReader(response.GetResponseStream());
var responseText = reader.ReadToEnd();

Hi

Thanks for the code.

Do you know where is the function UrlEncode ?

string postData = ???.UrlEncode("…");

Thanks.
Karima

@ Karima - I don’t think it is implemented in NetMF.

OK thanks

I found a simple version :
http://www.tinyclr.com/codeshare/entry/578

Bye
Karima