I am trying to execute a query that retrieves information from CRM Dynamics using a Simple OData Client library like this (C #):
var settings = new ODataClientSettings(resource + "/api/data/v8.0/"); settings.BeforeRequest = (request) => { request.Headers.Clear(); request.Headers.Add("Authorization", accesstoken.AccessTokenType + " " + accesstoken.AccessToken); }; settings.PayloadFormat = ODataPayloadFormat.Json; var client = new ODataClient(settings); var annotations = new ODataFeedAnnotations(); var transactions = await client.For("mss_transaccions").FindEntriesAsync(annotations); while (annotations.NextPageLink != null) { transactions = transactions.Union(await client.For("mss_transaccions").FindEntriesAsync(annotations.NextPageLink, annotations)); }
While this works, it is very slow, because my query in the mss_transaccions table has 7200 objects. I look at the output in Fiddler, and I see that it is trying to download about 20 MB of information.
I tried to run the same request in Google Chrome, and I realized that by default the received response is compressed in gzip format, starting from 20 MB to several 500 KB. Therefore, I conclude that Simple OData Client does not do any compression, and why it slows down so much.
In addition, a request from OData Simple Client requests metadata information that adds another 4 MB, while Chrome or a simple HttpClient request should not make this call.
Is there anything I can do to improve this and enable compression?
Thanks.
source share