1

I'm facing problem in getting response for a POST method web request in vb.net and the GET request is working properly and getting the response, while the same request is working fine in C# with the same steps followed here. So, can any one help me to try to sort out this

Here Url is a Elastic search engine and the data in postData variable is a json string and the response will also be is a json string

Dim request As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("HOSTIP:9200/es5078_1/_search?pretty=true")

    request.Method = "POST"
    Dim postData As String = CGeneral.gstrMsgNC(236)
    request.ContentType = "application/x-www-form-urlencoded"
    request.ContentLength = postData.Length
    request.Timeout = 100000

    Dim writer As StreamWriter = New StreamWriter(request.GetRequestStream())
    writer.Write(postData)
    request.Expect = ""
    request.AllowAutoRedirect = True
    request.AllowWriteStreamBuffering = True

    Dim response As System.Net.HttpWebResponse = request.GetResponse()

    Dim responseReader As StreamReader = New StreamReader(response.GetResponseStream())
    Dim result As String = responseReader.ReadToEnd()
SerG
  • 1,251
  • 4
  • 18
  • 37
  • I have similar problem but in C#. During sending a lot (hundreds in parallel) of indexing POST-requests to ElasticSearch I get `System.Net.WebException The operation has timed out System.IO.Stream GetRequestStream` for part of them. – SerG Sep 12 '14 at 08:08

0 Answers0