I'm having some problem's grabbing a response stream from a request that returning status code 422.
HttpWebResponse objResponse = (HttpWebResponse)wr.GetResponse();
The wr.GetResponse throws an webexception because the status code isnt 201.
So i can never get the response stream from the remote server. But it does return important information in the ResponseStream.
So my question is how to retrieve the ResponseStream on a request that doesnt return 201 but still returns data.
The WebException that is thrown contains a reference to the response from which you can get the response steam.
catch(WebException ex)
{
ex.Response.GetResponseStream();
}
Use TcpClient and send the HTTP Request manually. It's a pretty simple request format.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.