webrequest.httprequest not returning any value

96 views Asked by At
var baseAddress = "https://insights-collector.newrelic.com/v1/accounts/111111/events";
var http = (HttpWebRequest)WebRequest.Create(new Uri(baseAddress));
http.Accept = "application/json";
http.ContentType = "application/json";
http.Method = "POST";
http.Headers.Add("X-Insert-Key", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
ASCIIEncoding encoding = new ASCIIEncoding();
Byte[] bytes = encoding.GetBytes(jsondata);

**Stream newStream = http.GetRequestStream();**

newStream.Write(bytes, 0, bytes.Length);
newStream.Close();
var response = http.GetResponse();

var stream = response.GetResponseStream();
var sr = new StreamReader(stream);

content = sr.ReadToEnd().ToString();

when i execute the above code in my local machine i am getting response from newrelic website but when i move the same code to the windows server 2012, compiler is not going after this line

Stream newStream = http.GetRequestStream();

and also it was not throwing any exception.

0

There are 0 answers