Download Stream with RestSharp and ResponseWriter
Solution 1
You can check response.StatusCode and response.StatusDescription after executing the request.
Interestingly, if you use the DownloadData method as described here https://github.com/restsharp/RestSharp/wiki/Other-Usage-Examples there is no way to access this information as far as I can tell.
Solution 2
Currently You can use property AdvancedResponseWriter instead ResponseWriter.
The main difference is that AdvancedResponseWriter in addition to Response Stream gets IHttpResponse and You can check Response Status.
It should be working properly from version 106.6. https://github.com/restsharp/RestSharp/issues/1207
koalabruder
Updated on July 30, 2022Comments
-
koalabruder over 1 year
I donwnload a stream with RestSharp by using the ResponseWriter.
var client = new RestClient var request = new RestRequest(); // ... request.ResponseWriter = (ms) => { // how to detect the status code }; var response = client.Execute(request);
How can I found out the HTTP Status Code in the ResponseWriter? Is there a better way to download a Stream?