fork download
  1. Imports System
  2. Imports System.Net
  3. Imports System.IO
  4. Imports System.Text
  5.  
  6. Public Class Test
  7. Public Shared Sub Main()
  8. ' Create a request using a URL that can receive a post.
  9. Dim request As WebRequest = WebRequest.Create("http://w...content-available-to-author-only...h.in:8205/restPromo")
  10. ' Set the Method property of the request to POST.
  11. request.Method = "POST"
  12. ' Create POST data and convert it to a byte array.
  13. Dim postData As String = "username=nitco&password=nitco01&campaign-name=Nitco&to=9622205624&from=9622205624&text=Hello&unicode=True&dlr-url=202.177.175.171/fast-track"
  14. Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)
  15. ' Set the ContentType property of the WebRequest.
  16. request.ContentType = "application/x-www-form-urlencoded"
  17. ' Set the ContentLength property of the WebRequest.
  18. request.ContentLength = byteArray.Length
  19. ' Get the request stream.
  20. Dim dataStream As Stream = request.GetRequestStream()
  21. ' Write the data to the request stream.
  22. dataStream.Write(byteArray, 0, byteArray.Length)
  23. ' Close the Stream object.
  24. dataStream.Close()
  25. ' Get the response.
  26. Dim response As WebResponse = request.GetResponse()
  27. ' Display the status.
  28. Console.WriteLine(CType(response, HttpWebResponse).StatusDescription)
  29. ' Get the stream containing content returned by the server.
  30. dataStream = response.GetResponseStream()
  31. ' Open the stream using a StreamReader for easy access.
  32. Dim reader As New StreamReader(dataStream)
  33. ' Read the content.
  34. Dim responseFromServer As String = reader.ReadToEnd()
  35. ' Display the content.
  36. Console.WriteLine(responseFromServer)
  37. ' Clean up the streams.
  38. reader.Close()
  39. dataStream.Close()
  40. response.Close()
  41. End Sub
  42. End Class
Runtime error #stdin #stdout #stderr 0.1s 36184KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Unhandled Exception:
System.Net.WebException: Error: NameResolutionFailure
  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Net.WebException: Error: NameResolutionFailure
  at System.Net.HttpWebRequest.EndGetRequestStream (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
  at System.Net.HttpWebRequest.GetRequestStream () [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0