When making requests for reports via the WebTrends Web Services the best practice is to get the data compressed. When making an HTTP request it's really easy to make sure the web server will compress the data and speed up the transfer dramatically. So how does one get the content type set to make a request for compressed results programmatically? Easy, and here's a quick example I put together in C# with the standard HttpWebRequest objects.
[Test]
public void TestBaselineCompressedRequest()
{
var request = (HttpWebRequest)WebRequest.Create("https://somedomain/theservicepath/to/rest/?format=xml");
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
request.Credentials = new NetworkCredential("someUser", "somePassword");
var response = request.GetResponse();
var responseStream = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
string getTheResults = responseStream.ReadToEnd();
Assert.IsNotNull(responseStream);
Assert.IsNotNull(getTheResults);
}
This should get anyone kick started getting compressed data from WebTrends REST Web Services.