using RestSharp; ... var restClient = new RestClient("https://api.example.com/"); var restRequest = new RestRequest("users", Method.GET); restRequest.AddDecompressionMethod(DecompressionMethods.GZip); var response = restClient.Execute(restRequest);
using System.Net.Http; ... var httpClient = new HttpClient(); httpClient.BaseAddress = new Uri("https://api.example.com/"); var restRequest = new HttpRequestMessage(HttpMethod.Get, "users"); restRequest.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue("gzip")); var response = httpClient.SendAsync(restRequest).Result;In this example, we are making a GET request to the "users" endpoint using the HttpClient library. The Accept-Encoding header is being set to "gzip" to request a compressed response. The response variable will contain the result of the API call. Package library: RestSharp, System.Net.Http.