Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpStatus and DownloadData

Tags:

c#

restsharp

I'm trying to download a file (an image) with RestSharp using the DownloadData method

var client = new RestClient(baseUrl);

var request = new RestRequest("GetImage", Method.GET);

var response = client.DownloadData(request);

This works fine, but if the requests returns an error I cannot see the HttpStatus code.

I could make a Request and check the status:

var client = new RestClient(baseUrl);

var request = new RestRequest("GetImage", Method.GET);

var response = client.Execute(request);

var status = response.StatusCode;

But then I cannot get the image from the Content property.

I'm I missing something obvious?

like image 946
Michael Skarum Avatar asked Apr 27 '12 07:04

Michael Skarum


1 Answers

The image data would be in RestResponse.RawBytes

like image 101
John Sheehan Avatar answered Oct 21 '22 04:10

John Sheehan