Change accept header?

3,860 views
Skip to first unread message

bert

unread,
Feb 29, 2012, 4:47:29 PM2/29/12
to RestSharp
By default RestSharp uses the following accept header in the request:

accept: application/json, application/xml, text/json, text/x-json,
text/javascript, text/xml

I want to change it, for example to:

accept: application/json

I've tried with request.AddHeader("accept", "application/json") but
that didn't work.
Is there a way to change the accept header in the request?

Peter Johanson

unread,
Feb 29, 2012, 4:53:15 PM2/29/12
to rest...@googlegroups.com
bert,

The Accept header is automatically generated by inspecting the
"handlers" that are registered with the RestClient instance. One optin
is to use RestClient.ClearHandlers (); and then add back explicitly the
JSON deserializer with RestClient.AddHandler("application/json", new
JsonDeserializer ());

-pete

--

bert

unread,
Feb 29, 2012, 5:04:14 PM2/29/12
to rest...@googlegroups.com
ok thanks it works now!

Reply all
Reply to author
Forward
0 new messages