hello everybody ,
i took this code in internet to test a simple http request, but i have this exception: Eccezione first-chance di tipo 'System.Exception' in mscorlib.dll...
I am using netduino plus 2 .net micro framework 4.2
My goal is to send and to recieve the data from telegram's server(telegram is an application).
The code is the following:
using System;
using Microsoft.SPOT;
using System.Net;
using System.IO;
using System.Text;
class MyHttpRequest
{
public MyHttpRequest()
{
//nothing
}
public void Mymethod()
{
Debug.Print("Start...");
// Create a request for the URL.
WebRequest request = WebRequest.Create("https://api.telegram.org/....."); //here i have the exception
// Get the response.
WebResponse response = request.GetResponse();
// Display the status.
Debug.Print(((HttpWebResponse)response).StatusDescription);
// Get the stream containing content returned by the server.
Stream dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd(); //here i have the error when use URL: http://www.google.it
// Display the content.
Debug.Print(responseFromServer);
// Clean up the streams and the response.
Debug.Print("end");
reader.Close();
response.Close();
}
}
Can i use the WebRequest class if my URL is a https?
because when i change the url(for example http://www.google.it)i have another exception :
Eccezione first-chance di tipo 'System.ArgumentOutOfRangeException' in mscorlib.dll
if you can help me (if it is possible to write the code...)
Thank you
Regards.