You can customize your own Accept header using the AddHeader method ...
var client = new RestClient("http://example.com/api"); var request = new RestRequest("statuses/public_timeline", Method.GET); request.AddHeader("Accept", "application/vnd.twitter-v1+json"); var response = client.Execute(request); var json = response.Content;
This should work if you want to deserialize JSON yourself.
If you want to use the general Execute<T> method, which performs automatic deserialization for you, you will run into problems ...
From the RestSharp documentation on deserialization :
RestSharp includes deserializers for XML and JSON processing. Upon receiving the response, RestClient selects the correct deserializer to use based on the type of content returned by the server. The default values ββcan be overridden (see setting). Supported built-in content types:
- application / json - JsonDeserializer
- application / xml - XmlDeserializer
- text / json - JsonDeserializer
- text / xml - XmlDeserializer
- * - XmlDeserializer (all other content types are not specified)
This suggests that by default, if the response content type is not one of those listed, RestSharp will try to use the XmlDeserializer for your data. This is customizable, but with extra work.
source share