Retrieve Json data with HttpClient Retrieve Json data with HttpClient json json

Retrieve Json data with HttpClient


The problem is that the response is compressed and HttpClient does not automatically decompress it by default.

With WebClient, you can create a derived class and set the AutomaticDecompression of the underlying HttpWebRequest.

You can't do that with HttpClient, because it doesn't have any suitable virtual methods. But you can do it by passing HttpClientHandler to its constructor:

var client =    new HttpClient(        new HttpClientHandler        {            AutomaticDecompression = DecompressionMethods.GZip                                     | DecompressionMethods.Deflate        });