Content Other Than JSON

RestClient is biased towards RESTFul API’s returning JSON - by default if you don’t provide Accept and Content-Type headers then they are set to application/json.

However you can use RestClient to access anything, the only difference is implicit casting isn’t supported (without configuring a Pipeline) - the response is available as a string via ToString() and as the raw HttpResponseMessage.

dynamic google = new RestClient("https://www.google.com", new Headers(new { Accept = "text/html" }));

var result = await google.News.Get();

Assert.That(result.HttpResponseMessage.StatusCode, Is.EqualTo(HttpStatusCode.OK));
Assert.That(result.ToString(), Is.StringContaining("Google News"));

To send something other than JSON: pass a string to Post, Put or Patch and it’s sent as a raw string body; post forms with the FormUrlEncodedHandler; post files with the MultipartFormDataHandler. For anything else configure a Pipeline - you can pretty much do anything with RestClient.

Updated: