Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Posting gzipped JSON content with RestSharp

The title says it all: I'm trying to post gzipped JSON content to an IIS server using RestSharp.

I've searched and searched, but all I come up with are results that talk about handling a gzipped response: RestSharp compress request while making rest call to server

...or pages that simply claim that RestSharp supports gzip: http://www.bevanblackie.com/2012/03/restsharp-supports-gzip.html

It was really easy to compress responses from IIS by simply changing the IIS configuration. But I can't figure out how to post compressed content to the IIS web server. Ideally, RestSharp would handle this automatically and see if the server supports gzip compression and if not, send an uncompressed POST.

like image 921
Stefan Avatar asked Sep 12 '25 09:09

Stefan


1 Answers

  1. Set Content-Type as "application/json"

    request.AddHeader("Content-Type", "application/json");

  2. Set Content-Encoding as "gzip"

    request.AddHeader("Content-Encoding", "gzip");

like image 200
Pankaj Kapare Avatar answered Sep 14 '25 03:09

Pankaj Kapare