R
redmond
Using the below code for posting xml content throws "Badrequest (400)" and
only succeeeds after 3 or 4 tries. Hugely appreciate if somebody knows how to
fix this.
oHttpRequest =
(HttpWebRequest)WebRequest.Create(GlobalConfiguration.GetPartnerSetting(PARTNER_NAME, "ResidentURL"));
oHttpRequest.Timeout =
int.Parse(GlobalConfiguration.GetPartnerSetting(PARTNER_NAME,
"GatewayTimeoutMS"));
oHttpRequest.Method = "post";
oHttpRequest.ContentType = "text/xml";
oHttpRequest.ContentLength = arrPostData.Length;
//The foloowing
oHttpRequest.AllowWriteStreamBuffering = true;
oHttpRequest.KeepAlive = true;
oRequestStream = oHttpRequest.GetRequestStream();
oRequestStream.Write(arrPostData, 0, arrPostData.Length);
oRequestStream.Flush();
oRequestStream.Close();
//Make the request to the remote server
try
{
//This is where it
throws the BadRequest error
oHttpResponse = (HttpWebResponse)oHttpRequest.GetResponse();
}
catch (Exception ex)
{
throw new ApplicationException("The remote server could not be
contacted. " + ex.Message + ".", ex);
}
only succeeeds after 3 or 4 tries. Hugely appreciate if somebody knows how to
fix this.
oHttpRequest =
(HttpWebRequest)WebRequest.Create(GlobalConfiguration.GetPartnerSetting(PARTNER_NAME, "ResidentURL"));
oHttpRequest.Timeout =
int.Parse(GlobalConfiguration.GetPartnerSetting(PARTNER_NAME,
"GatewayTimeoutMS"));
oHttpRequest.Method = "post";
oHttpRequest.ContentType = "text/xml";
oHttpRequest.ContentLength = arrPostData.Length;
//The foloowing
oHttpRequest.AllowWriteStreamBuffering = true;
oHttpRequest.KeepAlive = true;
oRequestStream = oHttpRequest.GetRequestStream();
oRequestStream.Write(arrPostData, 0, arrPostData.Length);
oRequestStream.Flush();
oRequestStream.Close();
//Make the request to the remote server
try
{
//This is where it
throws the BadRequest error
oHttpResponse = (HttpWebResponse)oHttpRequest.GetResponse();
}
catch (Exception ex)
{
throw new ApplicationException("The remote server could not be
contacted. " + ex.Message + ".", ex);
}