Download Stream with RestSharp and ResponseWriter

I am loading a stream using RestSharp using ResponseWriter.

var client = new RestClient
var request = new RestRequest();
// ...
request.ResponseWriter = (ms) => {
  // how to detect the status code
};
var response = client.Execute(request);

How to find out HTTP status code in ResponseWriter? Is there a better way to download Stream?

+4
source share
1 answer

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 access to this information, as far as I can tell.

+3
source

All Articles