The httpRequest.GetResponse() method gets a status code of 422 (Unprocessable entity) and throws an exception. In this webservice I am using, I know that an XML response is also sent and I need to get that response in order to find out why the server could not process my request.
How do I get the XML response in the catch block?
try
{
// Submits the HTTP request to create the invoice and gets the XML response.
using (HttpWebResponse httpResponse = httpRequest.GetResponse() as HttpWebResponse)
{
// my code...
return httpResponse;
}
}
catch (Exception e)
{
}