I'm trying to request list of tags on StackExchange in JSON format by url, but problem is, that I'm getting some broken text instead of JSON, so I can't even parse it.
P.S. Done it with the help of RestSharp.
private void Refresh()
{
var client = new RestClient("http://api.stackexchange.com/2.2/tags?order=desc&sort=popular&site=stackoverflow");
var result = client.Execute(new RestRequest(Method.GET));
var array = JsonConvert.DeserializeObject<Root>(result.Content);
Platforms = array.Platforms;
}
If you make GET request to this URL using Fiddler, you will see that response has a header:
Content-Encoding: gzip
Which means that response is compressed with gzip. Good news is that HttpWebRequest can handle that:
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
After you add this row you will get nice and readable JSON.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With