0

Is it possible to somehow force System.Net.WebRequest.GetResponse to return me the message body even on failure?

The reason why I'm trying to achieve this is because when I get an error from a server (say, error 400 Bad Request), the GetResponse method fails and simply says that an error 400 Bad Request occurred. However, the server is sending additional information in the body that explain what exactly has failed and how to correct the request - though, I can never get to these data.

Trying to read the stream from GetResponse when an error occured doesn't work.

Any idea on how to get to these data?

Thanks

leopik
  • 2,323
  • 2
  • 17
  • 29

1 Answers1

0

I eventually found the exact question and a solution to my question. Anyway, here is the link in case somebody is having similar issue.

.Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned

Community
  • 1
  • 1
leopik
  • 2,323
  • 2
  • 17
  • 29