Getting an Exception when Trying to post Data to server C#

487 views Asked by At

I am using C#, .net micro framework 4.3. I am trying to post maek empty post to server but I am always getting the exception :

Program Started POST to :http://api.lyncagent.com/sendim?dnmf=yes&sender=xxxx&recipient=yyyy&message=ferastanan&priority=Normal&subject=NetMF POST complete. The thread '' (0x3) has exited with code 0 (0x0). #### Exception System.Net.Sockets.SocketException - CLR_E_FAIL (7) #### #### Message: #### Microsoft.SPOT.Net.SocketNative::getaddrinfo [IP: 0000] #### #### System.Net.Dns::GetHostEntry [IP: 0008] #### #### System.Net.HttpWebRequest::EstablishConnection [IP: 00e1] #### #### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] #### #### System.Net.HttpWebRequest::GetResponse [IP: 000c] #### #### Gadgeteer.Networking.HttpRequest::HandleRequestSync [IP: 01a8] #### #### SocketException ErrorCode = 10060 #### SocketException ErrorCode = 10060 A first chance exception of type 'System.Net.Sockets.SocketException' occurred in Microsoft.SPOT.Net.dll #### SocketException ErrorCode = 10060 #### SocketException ErrorCode = 10060 #### Exception System.Net.WebException - 0x00000000 (7) #### #### Message: host not available #### System.Net.HttpWebRequest::EstablishConnection [IP: 00f1] #### #### System.Net.HttpWebRequest::SubmitRequest [IP: 0019] #### #### System.Net.HttpWebRequest::GetResponse [IP: 000c] #### #### Gadgeteer.Networking.HttpRequest::HandleRequestSync [IP: 01a8] #### A first chance exception of type 'System.Net.WebException' occurred in System.Http.dll #### Exception System.Net.WebException - 0x00000000 (7) #### #### Message: #### System.Net.HttpWebRequest::GetResponse [IP: 00d3] #### #### Gadgeteer.Networking.HttpRequest::HandleRequestSync [IP: 01a8] #### A first chance exception of type 'System.Net.WebException' occurred in System.Http.dll

An exception occured while connecting to the Internet. Please, make sure that a valid URL is used and a network connection is up.

here is the code:

string url = "http://api.lyncagent.com/sendim?dnmf=yes&sender=xxxx&recipient=yyyy&message=" + "ferastanan" + "&priority=Normal&subject=NetMF";
        Debug.Print("POST to :" + url);
        POSTContent emptyPost = new POSTContent();
        var req = HttpHelper.CreateHttpPostRequest(url, emptyPost, "text/plain");


        req.ResponseReceived += new HttpRequest.ResponseHandler(req_ResponseReceived);
        req.SendRequest();
        Debug.Print("POST complete.");
0

There are 0 answers